I created like system in wordpress. And I created 'sayim_beyenme' table and created 'say_post_id' and 'total_post_likes' datas. Now I want to display my posts orderby total likes per each post. I get posts ids with array_map, but I dont know how can I order these posts by total_post_like values. For testing I have used 'title' This is my codes:
<?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',
));