• Resolved stephbretagne

    (@stephbretagne)


    Hello,

    As indicated in the title, I would like to display two posts (ID 897,208) before the other posts classified from the most recent to the oldest.

    My shortcode without this particular ranking:
    [display-posts title = "In this section" display-posts category_id = "7" display-posts include_date = "true" date_format = "d/m/Y" display-posts include_excerpt = "true" excerpt_length = "55" excerpt_more ="(....)" excerpt_more_link = "true" display-posts wrapper = "div" wrapper_class = "dp-categories" display-posts columns="3"]

    Thank you in advance for your help!

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

    (@billerickson)

    First, it looks like there’s some issues in your shortcode. You have display-posts listed many times in there. Stripping all of that out leads to the following shortcode:

    
    [display-posts title="In this section" category_id ="7" include_date="true" date_format="d/m/Y" include_excerpt="true" excerpt_length="55" excerpt_more="(....)" excerpt_more_link="true" wrapper="div" wrapper_class="dp-categories" columns="3"]
    

    Second, unfortunately there’s not a way to specify which posts appear first in a shortcode, unless you manually specify all the posts you want shown.

    For your use case, I think it would be simplest to use two shortcodes:

    1. Display your two posts (897, 208)
    2. Display recent posts from that category EXCLUDING those two posts (so they aren’t repeated)

    I also changed the columns to 2 since the first shortcode only has two posts in it. Leaving it as 3 columns would add a gap.

    
    [display-posts title="In this section" id="897, 208" orderby="post__in" order="ASC" include_date="true" date_format="d/m/Y" include_excerpt="true" excerpt_length="55" excerpt_more="(....)" excerpt_more_link="true" wrapper="div" wrapper_class="dp-categories" columns="2"]
    
    [display-posts exclude="897, 208" category_id ="7" include_date="true" date_format="d/m/Y" include_excerpt="true" excerpt_length="55" excerpt_more="(....)" excerpt_more_link="true" wrapper="div" wrapper_class="dp-categories" columns="2"]
    
    Thread Starter stephbretagne

    (@stephbretagne)

    Hello Bill and thank you very much for that very detailed answer!

    I didn’t understand that we shouldn’t repeat “display-posts” everywhere… Thanks for the info!

    Then, I came to the same conclusion as you (use 2 shortcodes) and I rethought my categories.

    So I created a new sub-category (89) for the posts that were to appear first and that, as time went on, will be more than two.

    I then excluded this category so that the posts would not appear twice.

    [display-posts title = "Droits des contractuels" category_id = "89" include_date = "true" date_format = "d/m/Y" date_query_column="post_modified" include_excerpt = "true" excerpt_length = "55" excerpt_more = "(...)" excerpt_more_link = "true" wrapper = "div" wrapper_class = "dp-categories" columns="3"]
    
    [display-posts title="Dans cette rubrique" category_id ="7" cat_not_in= "89" include_date="true" date_format="d/m/Y" include_excerpt="true" excerpt_length="55" excerpt_more="(...)" excerpt_more_link="true" wrapper="div" wrapper_class="dp-categories" columns="3"]
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display 2 posts before the others (sorted by date) in a category’ is closed to new replies.