If a user is logged in and has permission to edit/delete an article, this snippet will add a “Delete Post” link at the end of the listing for them to do so.
Category: Display Posts Shortcode
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 […]
Include the post categories in the listing
Display Posts can include a list of terms associated with each post in the listing. These can be categories, tags, or any custom taxonomy. If you set category_display=”true” it will include a listing of the categories. You can also list tags ( category_display=”post_tag”) or any custom taxonomy ( category_display=”taxonomy_name”). Here’s an example from this site. […]
List popular posts by total comments
Comment count can be a great indicator of a post’s popularity. You can use the orderby parameter to change how Display Posts sorts the results. If you have more social engagement than on-site commenting, you might try listing popular content by share count instead.
Limit the number of posts shown
Display Posts lists 10 posts by default, but you can change this using the posts_per_page parameter in a shortcode. For instance, if you only wanted to list two posts, use: If you want to list every post, use “-1” as the value: Set new default for posts_per_page If you find yourself typing the same value […]
Hide private / password protected content
Display Posts can be used to list – or exclude from listing – any content you’ve marked as “Private” or set with a password. Private Content Display Posts does not show private posts by default. It limits results to content with the “publish” status. If you create a private page, then use InstallThank YouThe Output […]
Date Queries
The date query feature in WordPress only works with the actual date columns in the WP database (post_date and post_modified). If you’re trying to use a date stored as metadata, you’ll want to use a Meta Query. Here are some examples of meta queries using dates: Display upcoming events from Sugar Events Calendar Display upcoming […]
Taxonomy Queries
Taxonomies are tools for organizing content in WordPress. Categories and tags are built-in taxonomies, and you can create additional taxonomies. Use the parameters below to query based on taxonomy terms. taxonomyThe taxonomy you would like to query tax_termThe term (or terms) you would like to include tax_operatorOperator to test. Possible values are ‘IN’, ‘NOT IN’, […]
Use template parts to match your theme’s styling
Display Posts lets you easily display posts based on any criteria you choose without any coding. It can be difficult to match your theme’s design for post summaries using just the shortcode and CSS. That’s where template parts come in. Styling belongs in a theme Your theme already contains the markup and styling for displaying posts. […]
Post Grid styling
You can create a great looking, column-based grid of posts with a bit of CSS. The next version of Display Posts will make it even easier to add a grid of posts. We’re building a custom block for the new content editor (Gutenberg) that will allow you to select different layout options. Example Shortcode Use […]