When you know exactly which posts you’d like to feature, you can use the “id” parameter to specify their post IDs and orderby=”post__in” to display them in the order you listed. In the example below, I want to highlight my Post Grid tutorial and an article on adapting the layout: Shortcode Example
Author: Bill Erickson
Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.
Reversed Ordered List
You can use the wrapper parameter to change the bulleted (unordered) list to a numbered (ordered) list: Example: But what if you want the numbers to go in reverse? Example: Once the code at the bottom of this post has been added to your site, you can reverse an ordered list by adding reversed=”true”.
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 thumbnail, medium, large (all controlled from Settings > Media), or […]
Add extra text after title
Let’s say you are using Display Posts to list products and would like to include ” in Peterborough” to the end of each title within the link. We’ll use the output filter to add a new parameter, after_title, and include that as part of the title. Usage: Display specific postsReversed Ordered ListDisplay image from post […]
Use the WordPress date format
If you use the include_date=”true” parameter, Display Posts will include the post’s date using the (n/j/Y) format. Ex: You can customize this using the date_format parameter (see Formatting Dates and Times). WordPress lets you specify a default date format in Settings > General > Date Format. If you would like to use that format in […]
Add Post ID class to each listing item
Display Posts adds a class of .listing-item to each post in the listing. You can customize the classes using the display_posts_shortcode_post_class filter. The following code adds a class to each listing item of post-{id} , so if the post has an ID of 123 it will have a class of post-123.
Add class to current post for styling
Display Posts adds a class of .listing-item to each post in the listing. You can customize the classes using the display_posts_shortcode_post_class filter. If you’re using Display Posts for a table of contents in a sidebar, it’s helpful to style the current post differently than the others. The code below will add a class of .current-list-item […]
Display post count as title of listing
You can use the title parameter in the shortcode to add a title above the listing of posts. But what if you want that title to dynamically include the post count? We’ll use the shortcode_atts_display-posts filter to modify the default parameters for the shortcode. If the shortcode does not have a title specified, we’ll give […]
Display meta value in output
Display Posts includes many display parameters for customizing what is displayed in the post listing output. You can include things like the post title, image, excerpt, content, date, author, categories, and more. You can use the output filter to both modify existing pieces of the output (ex: default image) and add your own custom pieces […]
Display author avatar
You can display the author name in the listings using Display specific posts by Bill EricksonReversed Ordered List by Bill EricksonDisplay image from post content if no featured image by Bill EricksonAdd extra text after title by Bill EricksonUse the WordPress date format by Bill EricksonAdd Post ID class to each listing item by Bill […]