好
我解决了自己的问题。如果将来有人需要它,您可以使用以下代码:
$query = new WP_Query( array(
\'cat\' => \'22\',
\'posts_per_page\' => -1,
\'orderby\' => \'meta_value\',
\'meta_key\' => \'meta_key_here\',
\'order\' => \'DESC\',
\'fields\' => \'ids\'
));
global $post;
$i = array_search( $post->ID, $query->posts ) + 1;
echo \'<div class="ranks">\';
echo \'<a href="/...">Post Ranking: </a>\';
echo "{$i}";
echo \'</div>\';
对于标记:
$query = new WP_Query( array(
\'tag_id\' => \'22\',
\'posts_per_page\' => -1,
\'orderby\' => \'meta_value\',
\'meta_key\' => \'meta_key_here\',
\'order\' => \'DESC\',
\'fields\' => \'ids\'
));
global $post;
$i = array_search( $post->ID, $query->posts ) + 1;
echo \'<div class="ranks">\';
echo \'<a href="/...">Post Ranking: </a>\';
echo "{$i}";
echo \'</div>\';