require($_SERVER['DOCUMENT_ROOT'].'/dynamic/wp-blog-header.php'); define('WP_USE_THEMES', false); if(!$_GET[page_id]){ // The Query query_posts( 'post_parent=367&post_type=page&order=ASC'); // The Loop while ( have_posts() ) : the_post(); $arr[]= $post->ID; endwhile; // Reset Query wp_reset_query(); wp_redirect($_SERVER[PHP_SELF].'?lang='.$_GET[lang].'&page_id='.$arr[0], 301 ); exit; }else{ // The Query query_posts( 'post_parent='.$_GET[page_id].'&post_type=page&order=ASC'); // The Loop while ( have_posts() ) : the_post(); $arr[]= $post->ID; wp_redirect($_SERVER[PHP_SELF].'?lang='.$_GET[lang].'&page_id='.$arr[0], 301 ); exit; endwhile; // Reset Query wp_reset_query(); } ?>