Display Posts Shortcode
[resolved] Can I pull list of posts from category excluding most recent post? (3 posts)

  1. sventhebaker
    Posted 3 years ago #

    I am looking to feature the most recent post, using a thumbnail etc. Is there a way to have a list right under the most recent post that just pulls 3 other posts that are older than the most recent?
    Example: Category X has posts from Aug 1, Aug, 2, Aug 3, Aug 4.
    I want to feature Aug 4 with thumb, but list Aug 3,2,1 below it.




  2. Bill Erickson
    Plugin Author

    Posted 3 years ago #

    This is a bit outside the scope of this plugin. For your particular instance I'd recommend creating a page template that altered what was displayed based on the post count.

    Right before the loop you would put $counter = 1;

    Then, inside the loop do something like:

    if ( 1 == $counter ) {
    [your markup for your first featured post]
    } else {
    [your markup for all other posts]
  3. Bill Erickson
    Plugin Author

    Posted 3 years ago #

    Actually, now that I've added a filter to the shortcode you can do this. It will only work if the shortcode is used only once on the page. Place this in your functions.php file:

     * Exclude the first post
     * @author Bill Erickson
     * @link http://wordpress.org/extend/plugins/display-posts-shortcode/
     * @link http://wordpress.org/support/topic/plugin-display-posts-shortcode-can-i-pull-list-of-posts-from-category-excluding-most-recent-post
     * @param $output string, original markup for an individual post
     * @return false or $output
    add_filter( 'display_posts_shortcode_output', 'be_exclude_first_post' );
    function be_exclude_first_post( $output ) {
    	global $exclude_first_post;
    	if ( !isset( $exclude_first_post ) ) {
    		$exclude_first_post = true;
    		return false;
    	} else {
    		return $output;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Display Posts Shortcode
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic