Reversed Ordered List

You can use the wrapper parameter to change the bulleted (unordered) list to a numbered (ordered) list:

[display-posts wrapper="ol" posts_per_page="5"]

Example:

  1. Display posts as a select dropdown
  2. Remove “by” when displaying author name
  3. Display specific posts
  4. Reversed Ordered List
  5. Display image from post content if no featured image

But what if you want the numbers to go in reverse? Example:

  1. Display posts as a select dropdown
  2. Remove “by” when displaying author name
  3. Display specific posts
  4. Reversed Ordered List
  5. Display image from post content if no featured image

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-posts wrapper="ol" reversed="true" posts_per_page="5"]

This code snippet goes in a core functionality plugin or Code Snippets.

/**
 * Display Posts, reversed list
 * @link https://displayposts.com/2020/04/17/reversed-ordered-list/
 */
function be_dps_reversed_list( $output, $atts ) {
	if( !empty( $atts['reversed'] ) && true === filter_var( $atts['reversed'], FILTER_VALIDATE_BOOLEAN ) )
		$output = str_replace( '<ol ', '<ol reversed ', $output );
	return $output;
}
add_filter( 'display_posts_shortcode_wrapper_open', 'be_dps_reversed_list', 10, 2 );

Filters used:

Published by 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.