views:

96

answers:

1

i have a specific single page which display a single post. the thing is that i want to display below it all the other posts which have the same special meta data and i made that to work as well.

the problem starts when i try to make pagination to the list of the posts below.

the single post url is something like that:

blog.com/somepost

and the pagination link to the second page of posts below looks someting like this

blog.com/somepost/page/2

and wordpress automatically redirects me back to

blog.com/somepost

how can i prevent it from redirecting me back?

btw, i"m using something like that:

i"m doing something like this:

while( have_posts() ):  the_post();

   //here printing the single post          

endwhile;

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;


$args = array(
   'meta_key' => '_btree_project_id',
   'meta_value' => $post->ID,
   'post_status' => 'publish',
   'paged' => $paged,
   'posts_per_page' => 8
);

$temp = $wp_query;

$wp_query = new WP_Query( $args );

while( have_posts() ): the_post();

   //looping through the related posts here 

endwhile;
A: 

The reading I've done about WordPress pagination gives me the impression that it is an imperfect feature. It requires the global var $wp_query which stems from the WP_Query object. WP_Query holds the global $wp_query which is necessary for making even basic pagination work. Custom queryies don't have access to $wp_query, nor do they own a var to control pagination. I assume you are using a custom query to grab that single post, and as this article points out, with custom queryies:

the “fix” is to trick WordPress into using the global $wp_query variable when using our own custom loops.

The article gives an example of utiilizing the global var in your custom query so that you have access to the query_vars that make pagination possible.

I expect that your permalink structure and a custom query that I'm guessing you are using might not be working because the global $wp_query var isn't available during your loop to show related posts.

What does your code to get, display, and paginate the related posts look like? Can you post?

kevtrout
hi,actually what you are describing is not the problem,first i use the $wp_query to show the single post which belongs to that page.next, i"m redefining the $wp_query var to hold a new WP_Query objectwith the related posts parameters (and pagnation data, which works fine BTW).the thing is when i try to go sotheblog.com/postname/page/2it automatically redirects me back totheblog.com/postnamebefore it event prints something..
Gilad
iv'e posted some code samples above
Gilad
Thanks for the code update, maybe the problem is with .htacces as posed here: http://wordpress.org/support/topic/pagination-with-custom-permalinks-broke-with-upgrade-to-30
kevtrout
And maybe use this plugin: http://wordpress.org/extend/plugins/category-pagination-fix/
kevtrout