我在wordpress中创建了like系统。我创建了“sayim\\u beyenme”表,并创建了“say\\u post\\u id”和“total\\u post\\u likes”数据。现在我想按每个帖子的总赞数显示我的帖子。我用array\\u map获取帖子ID,但我不知道如何按total\\u post\\u like值排序这些帖子。对于测试,我使用了“标题”,这是我的代码:
<?php
$results = $db->prepare("SELECT say_post_id FROM sayim_beyenme ORDER BY total_post_likes DESC LIMIT 3");
$results->execute();
$results = $results->fetchAll();
$like_posts = array_map(function(&$r) { return $r[\'say_post_id\']; }, $results);
if($like_posts) {
$postlar = new WP_Query(array(
\'paged\' => get_query_var(\'paged\', 1),
\'post_type\' => array(\'post\'),
\'posts_per_page\' => 9,
\'post__in\' => $like_posts,
\'orderby\' => \'title\',
\'order\' => \'ASC\',
));