If you would like to display the title of the current post or page, you can add the following code to add support for this shortcode:
Customize the query arguments passed to WP_Query.
FacetWP is an advanced filtering plugin for WordPress. It lets you build smart filters based on attributes of your content (categories, tags, metadata, publish date…). By default it applies only to the main query on the page, but it can also be applied to custom queries (more information). The code below will let you use […]
Display connected content using Posts to Posts plugin
The Posts to Posts plugin lets you to make connections between content types on your site. You could create a posts_to_pages connection for connecting relevant news articles to a specific page. For further reading, see the Posts to Posts documentation and my tutorial on Manually Curated Related Posts. With the code snippet below, you can […]
Display or hide sticky posts
WordPress lets you mark posts as “sticky” so they appear at the top of listings, regardless of publish date. You can prevent sticky posts from appearing at the top of Display Posts using: This doesn’t actually exclude sticky posts, it just prevents them from appearing at the top. Display sticky posts After adding the code […]
List posts in the current category
Display Posts lets you limit posts to a certain category with the category parameter. But what if you’d like to show other posts in the current post’s category without having to type it out each time. This is especially useful in widgets and sidebars since you can add the shortcode once and it will automatically update to […]
Display upcoming events from The Events Calendar
You can use Display Posts to list upcoming events from The Events Calendar. After adding the code snippet below to your site, you can generate a list of upcoming events with:
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 […]
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 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 […]