Support » Plugin: Display Posts Shortcode » [Plugin: Display Posts Shortcode] pagination

  • Resolved mrhayduke


    Hello. I’ve used this plugin on a site in development and works great and well documented. Thank you.

    Wondering if you have any thoughts about if/how one could use pagination when there are a lot of results. I know we can use posts_per_page=-1 to list all posts but if there are a lot (20, 30, 40, etc.) it gets to be an unwieldy page.



Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Bill Erickson


    The problem with pagination is that it would interfere with the query of the current page. If you have a multi-page article and you use the display posts shortcode with pagination, clicking “Next” will show the next results AND change the page content.

    If you need pagination, it’s really best to customize the main WordPress query.

    Thanks, Bill. I realize pagination isn’t something the plugin (which is great, btw) is intended to tackle. Appreciate the reply!

    I’ve gotten this plugin to work with pagination using WP-Page Navi, but you need to feel comfortable tweaking the plugin itself. I installed WP Page Navi and dropped in much of the code from this blog post: and it works!

    Would you be so kind as to post what changes you made to the plugin? Did you add code from WP Page Navi or just install the plugin?


    Yea would like to know how you did it aswell

    So, it’s been a little while now since I set this up, but here’s what I did (which worked):

    You need to open the display-posts-shortcode.php file in the plugin folder. Find the // Set up initial query for post // section. This is where you’ll be adding to the existing code and inserting the query that allows for pagination (this is a copy of what I created before the “// If Post IDs” section).

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

    Next – you need to add pagenavi. I inserted it after the ‘endwhile;’ like so:

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

    I’m no expert at this stuff, but I was able to hack a bit to get this working. I hope this helps you.

    Where’s the code? I see the part about pagenavi.

    My question has been resolved. I found a work around with the Advanced Excerpts plugin.



    Haven’t seen any resolutions? How come it was resolved?
    Any workaround yet?

    Did not realize my code snippet above had been chopped off some time ago. Here it is again. Hope this helps.

    // Set up initial query for post
    	$args = array(
    		'post_type' => $post_type,
    		'tag' => $tag,
    		'category_name' => $category,
    		'posts_per_page' => $posts_per_page,
    		'order' => $order,
    		'orderby' => $orderby,
    if( get_query_var( 'paged' ) )
    	$my_page = get_query_var( 'paged' );
    else {
    	if( get_query_var( 'page' ) )
    		$my_page = get_query_var( 'page' );
    		$my_page = 1;
    	set_query_var( 'paged', $my_page );
    	$paged = $my_page;
    // default loop here, if applicable, followed by wp_reset_query();
    $args = array(
    	// other query params here,
    	'paged' => $my_page

    In regard to “fruitshakes” and my post.
    “My question has been resolved. I found a work around with the Advanced Excerpts plugin.”

    I am not using this plugin as I found a better solution with “Advanced Excerpts”




    Will celebrate if you share your workaround on Advanced Exerpts for pagination.


    When I try this, it will show all categories in my list even I only set one category, how can I fix it?

    meanwhile, can I move the pagination to the bottom?


    Hi fruitshakes,

    Sorry I didn’t get notice of your post but just got one for the last post by tennyy. I wanted my category pages to show more than just the basic excerpt and using “Advanced Excerpts” was what worked for me. I use my categories as navigational aids to getting to specific types of posts. Not sure what you are after.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Display Posts Shortcode] pagination’ is closed to new replies.