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:
Display Posts outputs an unordered list (<ul>) by default, but you can change this to an ordered list or div using If you would prefer a different wrapping element, like a <section>, you can use the following:
If you find yourself typing the same parameters over and over, you can save time by changing the default attributes. These can always be overridden by specifying new attributes on an individual shortcode. For instance, let’s say you always list 20 posts with excerpts: We can use the following to set these as the default: […]
The title parameter lets you define a title to appear above the post listing. This uses the <h2> element by default. You can use the display_posts_shortcode_title_tag filter to modify what heading is used. The code below changes this to an h4.
By default, Display Posts displays nothing if no posts were found matching your query. You can specify content to display using the no_posts_message parameter. Using a filter You can also use the display_posts_shortcode_no_results filter to modify the no posts message. This is useful if you want to use the same message on all instances of […]
When using Display image from post content if no featured image The image_size parameter allows you to include an image in your Display Posts listing of any size you like. Here’s the description from the documentation: image_sizeSpecify an image size for displaying the featured image, if the post has one. The image_size can be set to […]
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 […]
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 […]
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:
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.