1

I'm developing a simple rank plugin, which allows visitors to like the posts and also shows the total like scores for each tag in the plugin's admin page. I need both post IDs (in order to reach the tag data of them) and like values.

This is my query at the moment:

$args = array(
    'meta_key' => '_Like',
    'orderby' => 'meta_value',
);

$query = new WP_Query($args);

But this query returns the complete post object, it's not efficient for the memory. I only need _Like value and the post_id. Is there a better query for this ?

1 Answer 1

0

You will need to create your own MySQL query to achieve this. You may use PHP builtin functions or WPDB which is a MySQL wrapped used by WordPress:

https://codex.wordpress.org/Class_Reference/wpdb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.