Support » Fixing WordPress » get_query_var('paged') is always 1? Paginating custom post type.

  • Leo Blanchette

    (@leoclipartillustrationcom)


    I’ve been trying to paginate results on a custom post type. While the “paginate_links” function seems to work, get_query_var(‘paged’) always returns a 1.

    What causes this? How can I solve it?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Kurt

    (@highfxmedia)

    Leo:

    Are you using a page template? If yes, change it to this:

    (get_query_var('page')) ? get_query_var('page') : 1;

    Note that it’s page vs. paged.

    For reference: http://codex.wordpress.org/Function_Reference/get_query_var

    I was running a custom loop in a page template and it drove me nuts for several hours.

    Leo Blanchette

    (@leoclipartillustrationcom)

    Thank you Kurt, this has been getting me for more than a few hours to say the least!

    I changed “paged” to “page” and the loop still doesn’t respond. Testing, though, if I turn the “1” to a “2” things do respond. So I’ve isolated the problem to something in the get_query_far function.

    Also, its worth noting that I’m not using this either in a page template or archive, but in a different area. Does that change the game at all?

    Thanks for your help!

    Leo Blanchette

    (@leoclipartillustrationcom)

    I might have gotten closer to the problem.

    http://localhost/symbiostock_communicator.php/page/2/

    print_r($_GET); returns empty array. So the URL rewriting isn’t happening?

    This is being used on a special root-level script which is meant for other websites to dial in and get results. It includes wp-load.php. Perhaps this method is leaving out something crucial?

    Leo Blanchette

    (@leoclipartillustrationcom)

    small update –

    when I put up raw url variables like ?page=7 and skip get_url_var and just do $paged = ($_GET[‘paged’]) everything works fine.

    Building for the long-term however I’m trying to avoid work-arounds.

    Kurt

    (@highfxmedia)

    I found this which states that including wp-load.php does not parse the URL or run the query: http://stackoverflow.com/questions/13860577/wordpress-wp-load-php

    Otto says, don’t include wp-load.php: http://ottopress.com/2010/dont-include-wp-load-please/ implying that the script is not written in the best manner.

    Leo Blanchette

    (@leoclipartillustrationcom)

    Thanks. I suspected that might have been a part of the problem.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘get_query_var('paged') is always 1? Paginating custom post type.’ is closed to new replies.