Support » Fixing WordPress » $paged and WP_Query pagination

  • Hi There,

    I’m having a problem adding a pagination in my custom query.
    The code below show me 2 posts and I would like to create a second page for the others one.

    Could you tell me what I’m doing wrong?

    Thanks:)

    http://pastebin.com/HHBk3hFW

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The wp_link_pages() function is designed to split a single long post into multiple pages. You need to use the wp_next_posts_link() and wp_previous_posts_link() functions.

    For example, like this:

    <div class="navigation">
    	<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    	<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>

    Thanks for your answer! I’ve tried but did not work.

    Finally I’ve used wp-pagenavi plugin

    wp_pagenavi(array('query' => $my_query ) );

    and changed

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

    like in this post:
    http://wordpress.org/support/topic/wp-pagenavi-with-custom-query-and-paged-variable

    Hope that will help somebody.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$paged and WP_Query pagination’ is closed to new replies.