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 the current search resultsAdd class to current post for stylingDisplay post count as title of listingDisplay the current postDisplay connected content using Posts to Posts pluginPagination in Display PostsList […]
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.
Display posts as a select dropdown
The Display Posts plugin lets you create a list of posts using a wide range of query parameters. It will display the result as a bulleted list by default. The code below will turn it into a select dropdown, and selecting a post will take you directly to that post. After adding the code to […]
Remove “by” when displaying author name
You can include “by [the author name]” in the Display Posts listing by adding include_author=”true” to your shortcode. If you’d like to remove the “by” and only display the author name, add the code below to your theme’s functions.php file.
Display specific posts
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
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 the current search resultsDisplay posts as a […]
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 […]