Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$loop = new WP_Query( array(
'posts_per_page' => 20,
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_key' => 'shared_counts_total',
) );
if ( $loop->have_posts() ) {
$posts .= '<ol>';
while ( $loop->have_posts() ) {
$loop->the_post();
$shares = get_post_meta( get_the_ID(), 'shared_counts_total', true );
$posts .= sprintf( '<li><a href="%s">%s (%s %s)</a></li>',
esc_url( get_permalink() ),
get_the_title(),
esc_html( $shares ),
esc_html( _n( 'share', 'shares', $shares, 'shared-counts' ) )
);
}
$posts .= '</ol>';
}
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.