[wp-trac] [WordPress Trac] #9788: Possible bug with get_the_excerpt
and paged content via <!--nextpage-->
WordPress Trac
wp-trac at lists.automattic.com
Mon May 11 18:17:51 GMT 2009
#9788: Possible bug with get_the_excerpt and paged content via <!--nextpage-->
--------------------------+-------------------------------------------------
Reporter: alexkingorg | Owner: anonymous
Type: defect (bug) | Status: new
Priority: normal | Milestone: Unassigned
Component: General | Version: 2.7.1
Severity: normal | Keywords: get_the_excerpt wp_query
--------------------------+-------------------------------------------------
When doing a custom WP_Query and loop, I found odd behavior with paged
content on pages > 1.
For example, my custom loop worked great on page 1 of a paged post -
properly showing content from the page I was querying. However, on pages 2
and 3 of the paged post, my custom loop showed the content from the
currently displayed page of the post.
Example code:
Not working--
{{{
global $post;
$about_query = new WP_Query('pagename=about');
while ($about_query->have_posts()) {
$about_query->the_post();
$about_text = get_the_excerpt();
}
}}}
Working--
{{{
global $post, $wp_query;
$page = $wp_query->query_vars['page'];
// temporary - resetting below
$wp_query->query_vars['page'] = null;
$about_query = new WP_Query('pagename=about');
while ($about_query->have_posts()) {
$about_query->the_post();
$about_text = get_the_excerpt();
}
$wp_query->query_vars['page'] = $page;
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9788>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list