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' );
See the WP_Query orderby
docs for more info.
Related Posts:
- How to list commenters and days since last commented
- the_date() not working
- Query multiple custom post types in single loop
- The correct method to pass query vars in AJAX using ajaxurl
- How to search display_name column when using WP_User_Query
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- How to order WP_User_Query results to match the order of an array of user IDs?
- Display user’s total comment count outside The Loop
- Facebook Comment Count
- Alter query on edit.php
- Getting the comment number relative to all the post’s comments
- How to output a permanently delete comment link?
- How to find objects by terms
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- edit_comment_link is not showing for comment author
- Limit 1 global comment per minute
- Create Page To Count Comments For Each Post In WordPress Site
- comments sorting incorrectly across multiple pages
- Commenting out unwated CSS/scripts in HTML with PHP
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- wp-comments-post.php file returns a blank page
- php function to display commenter username or login
- Genesis framework comments broken?
- check if comment submitted was successful
- register_taxonomy() take much queries
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- Alter required message using comment form api
- Odd / Even posts add class minus first post
- Get post id within comments loop
- unable to use ‘new WP_Query’ in AJAX call
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- WordPress comment submit button substitutes/options
- How to add div blocks after certain set of post
- How to add text to the start of all comments?
- Does anyone know all parameters of get_comments()
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- Appended comments but they show up above the content instead of below
- get comment data using comment id
- Removing the comment function within wordpress
- working with term_relationships table
- wp_delete_comment takes two tries to delete – then deletes all comments
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- WordPress query undefined offset in loop
- Can I make get_users() query global?
- Send a mail to specific address in a custom field when a new comment is made on a specific post
- Issue with custom loop in Archive page
- How to display SQL query that ran in WC_Order_Query?
- Custom Post type slider with thumbnail navigation
- Parse error: syntax error, unexpected ‘}’ [closed]
- Shortcode to pull posts
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- Fetching Initials of the Commentator in the WordPress Website
- get_comments_number() returns 0
- How can I include the user id inside of a shortcode php output?
- WordPress PHP syntax doesn’t seem to be working correctly
- Restrict characters in comment section
- Querying for specific tags
- How to get thumbnail with pure PHP in a WordPress database?
- Limit tags shown in post
- Why my query does not run with prepare
- Conditionally load class in the comment section of the post page
- mySQL queries are executed twice on wordpress website
- How to get comment_ID by post_ID in wordpress
- List of Events with Multiple Dates: Only NEXT Date
- Echo array value
- Undefined variable: row?
- Comment_author_url doing nothing
- Fatal error: Cannot redeclare comment_theme()
- I don’t have comments.php… how do I customize my comment fields
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Query pulling a single post per month
- WordPress Custom Query: Combining Two Functions
- SQL error with custom query
- WordPress is removing query variables like page, p from the URL of a custom static page
- WordPress Conditional / Multiple Taxonomy Query
- How can I modify this code to make the search box include tags and meta
- Reject all malicious URL requests functions.php
- Advanced Query posts
- How can I check that the acf field value is not a duplicate when adding a post?
- Build A Custom SQL Query for WordPress Search
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- My Custom Post Type AJAX Query is Returning no posts – why?
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Add custom field on admin dashboard comments / reviews
- Show all people who commented on all posts by an author
- Display articles with a different template in the home page | Solved |
- array wordpress when get is null
- Reading URL Parameters
- How to pass parameters in wordpress shortcode?
- Display the list of user’s comments + the post title + date
- Commenting requires wordpress login, wordpress discussion and post comments tick boxes are checked
- Category Page Displaying all Pages
- Comments on my custom post type
- Fetch commens from a specific post