0
我想在wordpress中的自定义查询中返回帖子的等级。我的代码目前是Wordpress在查询中查找帖子索引
function post_rank($post_type,$meta_value,$post_id) {
$args = array (
'post_type' => $post_type,
'meta_key' => 'totalvotes',
'order' => 'DESC',
'orderby' => 'meta_value_num',
'post_status' => '\'submitted\'
);
$the_query = new WP_Query($args);
$total_in_search = $the_query->found_posts;
$rank_in_search = array_search ($the_query,$post_id) +1 ;
$overall= $rank_in_search ."/".$total_in_search ;
wp_reset_postdata();
return $overall;
}
但我似乎无法找到帖子索引。任何想法,将不胜感激。
你知道在循环之外是否有办法做到这一点? – VC10 2015-03-19 12:24:00
关于这篇文章有什么信息吗? – yuyokk 2015-03-19 12:28:17
post_id。我想要做的是获得我的帖子内的职位排名元总票数排序。 – VC10 2015-03-19 21:04:43