admin管理员组文章数量:1122846
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 ?
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
Reset to default 0You 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
本文标签: wp querySelect only post id and meta value with WPQuery
版权声明:本文标题:wp query - Select only post id and meta value with WP_Query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736290005a1928423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论