SQL Statement for getting custom postfield
-
Hello,
I created a post_ranking field in the wp_posts table.
Now I want to get the posts sorted by their post_ranking.
I don’t get any Post back with my statement:add_filter('posts_orderby', 'ranking_order'); function ranking_order($orderby) {global $wpdb; $orderby = "SELECT distinct $wpdb->posts.* from $wpdb->posts where $wpdb->posts.post_type = 'listing' order by $wpdb->posts.post_ranking DESC"; return $orderby;}I’m glad for any help!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘SQL Statement for getting custom postfield’ is closed to new replies.