649 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

I am building a “one-page” theme and a little stuck… It was working before I upgraded to 3.9 (worked on 3.8)

$args = array(
    'sort_order' => 'ASC',
    'sort_column' => 'menu_order',
    'hierarchical' => 1,
    'post_type' => 'page',
    'post_status' => 'publish',
 );
 $pages = get_pages($args);
 foreach ($pages as $page_data) {
  $content = apply_filters('the_content', $page_data->post_content);
 echo $content;
}

It’s displaying the first page but not the rest so it’s breaking the sequence but there are no WP debug / php errors and I can’t see why it should break!

Any ideas?

72 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
ThemesHolic says

Try with query_posts($args).

Remember to add wp_reset_query(); at the end of the cycle.

649 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

Try with query_posts($args). Remember to add wp_reset_query(); at the end of the cycle.

No change, it’s wierd as as it worked before

Found the issue, for some reason the theme started using another template file :|

1483 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 more
OriginalEXE says

Try with query_posts($args). Remember to add wp_reset_query(); at the end of the cycle.

Never use query_posts() :)

72 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
ThemesHolic says


Try with query_posts($args). Remember to add wp_reset_query(); at the end of the cycle.
Never use query_posts() :)
The exact use-case that query_posts() was designed for: using a custom page template as an archive of posts, so it’s perfect for a custom one page template :)
3243 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 4 years
+1 more
organicbee says



Try with query_posts($args). Remember to add wp_reset_query(); at the end of the cycle.
Never use query_posts() :)
The exact use-case that query_posts() was designed for: using a custom page template as an archive of posts, so it’s perfect for a custom one page template :)
http://codex.wordpress.org/Function_Reference/query_posts nope.
Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use of pre_get_posts hook, for this purpose.

use http://codex.wordpress.org/Class_Reference/WP_Query

380 posts
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has been part of the Envato Community for over 3 years
  • Sells items exclusively on Envato Market
+2 more
kaaz says
try this
$pages = array();
$pages_obj = get_pages( 'sort_column=post_parent,menu_order' );  

foreach( $pages_obj as $page ){
    $pages[ $page->ID ] = $page->post_name; 
}

//all pages in array
$pages
380 posts
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has been part of the Envato Community for over 3 years
  • Sells items exclusively on Envato Market
+2 more
kaaz says
custom loop
    $loop = new WP_Query( array( 'post_type' => 'page', 'posts_per_page' => -1 ));

    if( $loop->have_posts() ) :

        while( $loop->have_posts() ) : $loop->the_post();

            the_content();

        endwhile;

        wp_reset_query();

    else :

       echo '<p>Sorry, no pages were found.</p>';

    endif;
180 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
juarathemes says

WP_Query() is your best friend mate ;)

by
by
by
by
by
by