New answers tagged

0 votes
Accepted

Pre_get_comments and orderby comment_karma

With the help of @f3bruary from the WordPress Chat Discord server, the solution is this: add_filter( 'posts_orderby', [ $this, 'orderby_comment_karma' ] ); add_filter( 'pre_get_comments', [ $this, '...
Aristocles's user avatar
1 vote

How to use parse_query() to add an additional filter based on content to page search?

There is only one parameter that will filter your results to posts that contain a value in the content, s aka search, but doing so would break the search box. Unless you write code that on save ...
Tom J Nowell's user avatar
  • 59.2k
0 votes

how to ensure url uses post_name and not query post id?

I found two possible solutions to my problem : 1. the link to the post should not use permalink the problem is actually that a draft post has a permalink with its post_id instead of post_name, as ...
hugogogo's user avatar
  • 111
1 vote

Pre_get_comments and orderby comment_karma

I think you're close with your 2nd snippet, but you should be using meta_value_num instead of meta_key_num. $query->set( 'meta_key', 'comment_karma' ); $query->set( 'orderby', 'meta_value_num' )...
Pat J's user avatar
  • 11.8k
0 votes

custom query to get posts

you are not preparing your query correctly. First of all the data should be fetched associatively and you are displaying it differently. for code practice its bad.| regarding your actual error. your ...
JimMorrison's user avatar

Top 50 recent answers are included