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 specific posts
  2. Reversed Ordered List
  3. Display image from post content if no featured image
  4. Add extra text after title
  5. Use the WordPress date format

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

  1. Display specific posts
  2. Reversed Ordered List
  3. Display image from post content if no featured image
  4. Add extra text after title
  5. Use the WordPress date format

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.