[wp-trac] [WordPress Trac] #25246: Make WP_Query (pagination) to load after template is loaded
WordPress Trac
noreply at wordpress.org
Fri Sep 6 23:56:31 UTC 2013
#25246: Make WP_Query (pagination) to load after template is loaded
--------------------------+------------------------------
Reporter: alexvorn2 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by alexvorn2):
Replying to [comment:1 markoheijnen]:
> I'm not sure what you are requesting. {{{pre_get_posts}}} seems to be
the proper filter for this things.
As I mentioned in the ticket is that we can use the filter `pre_get_posts`
to modify the value but I this seems not the good thing when we have a
custom property in the arguments of a custom query, example:
The Query
{{{
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 3,
'paged' => $paged
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<p>' . get_the_title() . '</p>';
}
}
}}}
So if we have only 4 posts and we want to use the posts_per_page property
to show 3 posts it works, but we will go to page/2 to show the last 1
posts, it will show as a 404 error page instead.
So that's why I opened this ticket, I request this.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25246#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list