0

I am developing a Wordpress theme that uses a lot of AJAX. It is composed of two main pages: the index, which displays a list of posts, and a viewer (similar to single.php).

When a post is clicked in index.php, Wordpress takes the user to viewer.php, which displays the post.

In viewer.php the selected post is displayed, and the links prev an next will load the previous or next posts with AJAX, instead of the current one.

My problem is that in index.php, different category filters can be applied, so I would want the exact sequence of posts displayed in index.php passed to viewer.php, so the next and post will use the sequence of posts that was displayed in the homepage.

I've been reading the docs to understand how WP handles the $wp_query info, but I am not sure I understand it, so I would appreciate your help.

1

In your index.php

global $query_string;
setcookie('my_wp_query', $query_string);

or

global $query_string;
$_SESSION['my_wp_query'] = $query_string;

whatever you prefer.

4
  • Sorry Dick but I am not sure I understood. Could you explain what $query_string contains? If I understood correctly, if index.php doesnt have any filters applied $query_string will be empty. Plus every filter refresh is done via AJAX, so I am not sure $query_string would work
    – 0al0
    Aug 3 '11 at 13:06
  • $query_string holds the current loop query.
    – user7582
    Aug 3 '11 at 13:08
  • In my index.php, without any filters aplied, its empty
    – 0al0
    Aug 3 '11 at 13:16
  • It has to be. Try querying posts for a category or any other criteria and you will see the difference.
    – user7582
    Aug 3 '11 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.