I have blog post counts which happen when a user views a blog post via ajax and the rest api.
In the database I have a meta key and value like so:
table: wp_postmeta
post_id: blog post ID
meta_key: blog_post_count
meta_value: number ie: 1, 2, 3 etc.
This basically stores the blog post ID and the count. On a page, I am trying to display the ID with the highest count only.
$views = new WP_Query( array(
'orderby' => 'meta_value_num',
'meta_key' => 'blog_post_count',
'order' => 'DESC',
'posts_per_page' => 1
) );
Running this in a standard wordpress loop however displays all posts and not with the highest count first so my Query is obviously not correct.