When using Display the current search results If you would like to use Display Posts on a search results page, you can add the following code to add support for this shortcode: [display-posts s="current"] View the code on Gist. Display posts as a select dropdown The Display Posts plugin lets you create a list of posts […]
Category: Display Posts Shortcode
Display multiple authors using Co-Authors Plus
Co-Authors Plus lets you assign multiple authors to a post. The code below integrates Co-Authors Plus with Display Posts so your post listings will include all authors. This can also be installed as a plugin: CoAuthors Plus Addon Usage Customization The following parameters can be added to the shortcode to customize the output of the […]
Exclude posts already displayed
If you’re using the Display Posts Shortcode multiple times in one page, you can use this to exclude already displayed posts from new shortcode queries. This will prevent duplicate posts. If you have other, non-Display Posts queries running on the page and would like to exclude them as well, you’ll need to modify those queries […]
Add category classes
I’m using the short code but there are some categories I would like to show in one color and then other categories should show in a different color. LesTexas60 You can use the display_posts_shortcode_post_class filter to customize the classes added to each post. Here’s how to add a class for each category attached to a post:
Polylang support
If you are using Polylang or Polylang Pro to translate content on your website, you can also query by posts in a specific language. See the documentation for more information.
Display default image
The image_size parameter lets you include a thumbnail in your post listing, but it only works if the post has a featured image attached to it. The code snippet below lets you specify a default image ID to use in case a post doesn’t have a thumbnail. You can find the image ID by going […]
Display upcoming events from Sugar Event Calendar
Sugar Calendar, like most other event calendars, stores the event dates as metadata. To sort your results by the event date (meta_key is sc_event_date_time) use: That will list every event starting with the oldest to newest. If you want to list only upcoming events, we’ll need to do a meta query. This specific meta query […]
Show siblings to current page
Is there any way to show siblings of the current page? TIA! Jay Collier Yes, you can use the following shortcode: That will list all the subpages with the same parent as the current page