meta_key from mysql database
-
I have the plugin “WTI Like Post” installed and its working. But I’m missing a feature to order the posts by the like count.
In wti_like_post.php I found the code to query the mysql database for the like count:function GetWtiLikeCount($post_id) { global $wpdb; $show_symbols = get_option('wti_like_post_show_symbols'); $wti_like_count = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post WHERE post_id = '$post_id' AND value >= 0"); [...] return $wti_like_count; }
Under the table “wti_like_post” there is a column “value” which stores int values (the like count which I need as a meta_key).
What I want to do: On a specific_page.php I want to loop through the posts and order them by the like count. I think I should use a meta_key, but how can I define “value” from the mysql connection as a meta_key ?
So what I want to do is:
$likes = // Get_the_meta_key_from_mysql_somehow $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args= array('meta_key' => $likes, 'orderby' => 'meta_key_num', 'paged' => $paged ); query_posts($args);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘meta_key from mysql database’ is closed to new replies.