WordPress.org

Ready to get started?Download WordPress

Forums

WP-Paginate
Unable to get page number and advance (3 posts)

  1. chrisamacdonald
    Member
    Posted 3 years ago #

    Hey -

    So I have been trying to fiqure out this issue, here and there for weeks, I have a solution, but not a good one.

    Here is the problem:
    The navigation does not advance and shows the same posts due to the paginate function not being able to grab the current page number. It shows up fine and shows the number of pages needed, but clicking on the page numbers shows the same page 1 and posts and the url will change to 2/3/4, etc. You can see it in action here: http://blog.rosettastone.com at the bottom of the page.

    Here is what I am using in the loop:

    query_posts('cat=4&paged='.get_current_page());
    		if(have_posts()){
    		while(have_posts()){
    		the_post();
    		global $more;
    		$more = 0;

    The get current page is the hack, that I do not want to use and it looks like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I have been told the following:
    "Calls to query_posts() made within the theme have no affect on pagination. To affect pagination links you need to hook into the parse_query action and manipulate the main query. Paging is done off of the results of the main query."

    As well as:
    Look into the parse_query filter and see if I can do what is needed there . . .

    Can you help? I have not worked much with filters (learning that stuff now) and could use some help on this simple, yet difficult issue. I would rather do it right vs. using the hack I worked out and pieced together.

    http://wordpress.org/extend/plugins/wp-paginate/

  2. chrisamacdonald
    Member
    Posted 3 years ago #

    Here is a link to the code moderated above:
    http://pastebin.com/embed_js.php?i=Bxs0WZtQ

    I have also tried:

    if(have_posts()){
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        	query_posts($query_string . "&cat=4");
    		while(have_posts()){
    		the_post();
    		global $more;
    		$more = 0;
  3. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    It should look something similar to:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("YOUR-PARAMETERS&paged=$paged");

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic