admin管理员组文章数量:1287774
I'm rather new to Wordpress development, and i have been making my own code to count and display views count on posts. Now, what i'm trying to do is get the homepage to sort these posts in descending order, ordered by view count.
Is there anyway to replace the query that fetches the posts list with this kind of query ?
SELECT posts.*, meta.meta_value FROM wp_posts AS posts
INNER JOIN wp_postmeta AS meta
ON posts.ID = meta.post_id
WHERE posts.post_type = 'post' AND posts.post_status = 'publish' AND meta.meta_key = 'post_views_count'
ORDER BY meta.meta_value DESC;
I have been trying to look at the query object in the documentation but i'll admit it's been a struggle to get this to work.
If anyone would be so kind to explain to me how to get there, so i can learn a bit more about this, if you have the time to spare, of course.
Thanks in advance.
本文标签: querySorting my posts on homepage my specific value in postmeta table
版权声明:本文标题:query - Sorting my posts on homepage my specific value in post_meta table 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741328155a2372608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论