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:
- Display posts as a select dropdown
- Remove “by” when displaying author name
- Display specific posts
- Reversed Ordered List
- Display image from post content if no featured image
But what if you want the numbers to go in reverse? Example:
- Display posts as a select dropdown
- Remove “by” when displaying author name
- Display specific posts
- Reversed Ordered List
- 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:
display_posts_shortcode_wrapper_open