WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] Use with WP_Query (not query_posts) (4 posts)

  1. alxvallejo
    Member
    Posted 1 year ago #

    When I go to page 2, I see the same posts as on page 1!
    You're using query_posts() wrong. See The Right Way To use query_posts()

    I've read in a multitude of places that query_posts should be used as a last resort. It generally is a shorter way of constructing a new Loop (new WP_Query).

    So, why does the FAQ insist that query_posts should be used?

    Also, does anyone know why my styles are being queued when I use wp_pagenavi in the admin section?

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

  2. alxvallejo
    Member
    Posted 1 year ago #

    Styles issue resolved:

    add_action( 'admin_enqueue_scripts', array( __CLASS__, 'stylesheets' ) );

    Added to core.php, Line 273

  3. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    So, why does the FAQ insist that query_posts should be used?

    Because people forget to pass the query instance to wp_pagenavi() and then come here and say the plugin is broken.

    Correct usage:

    $my_query = new WP_Query( ... );
    
    wp_pagenavi( array( 'query' => $my_query ) );
  4. alxvallejo
    Member
    Posted 1 year ago #

    Thanks scribu. Have you been able to use wp_pagenavi on the admin side? I've heard that the paged variable for the query doesn't register on the admin side - could be wrong though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.