1058 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+5 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?

89 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Helped protect Envato Market against copyright violations
+3 more
ThemesHolic
says

Try with query_posts($args).

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

1058 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+5 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 :|

1554 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
+2 more
OriginalEXE
says

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

Never use query_posts() :)

89 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Helped protect Envato Market against copyright violations
+3 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 :)
3439 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Achieved the monthly Community Superstar Award
  • Located in United States
+2 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

405 posts
  • Has sold $40,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a Most Wanted contest
  • Has been a beta tester for an Envato feature
+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
405 posts
  • Has sold $40,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a Most Wanted contest
  • Has been a beta tester for an Envato feature
+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;
455 posts
  • Has been part of the Envato Community for over 1 year
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Has referred 1+ members
+2 more
juarathemes
says

WP_Query() is your best friend mate ;)

by
by
by
by
by
by