How to order “top rated” results by date and meta key?

Your syntax is off – I can see you’re trying to add meta_value as an orderby param, but you’ve actually added as it an array entry – this is why formatting and indentation is important! $rate_query = new WP_Query([ ‘post_type’ => ‘movies’, ‘orderby’ => ‘date meta_value_num’, ‘meta_key’ => ‘wtf_rscore’, ‘posts_per_page’ => 14, ]);

Remove divs and spans from post content

Im not sure what you are actually doing here but I think you are looking to create a block of code from the post content then strip unnecessary tags. I would use strip tags: https://www.w3schools.com/php/func_string_strip_tags.asp <?php require “wp-config.php”; // Post Types to include $args = array( ‘posts_per_page’ => ’50’, ‘post_type’ => array( ‘product’, ‘product-variation’ ) … Read more

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Nothing. You shouldn’t need to set the post type. Your taxonomy archive is presumably already querying the correct post type. function customize_customtaxonomy_archive_display ( $query ) { if ( $query->is_tax( ‘country’ ) ) { $query->set( ‘meta_key’, ‘start_date’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); $query->set( ‘order’, ‘ASC’ ); } } Note: $query->is_main_query() is redundant when checking $query->is_tax(), because … Read more

How to hook the pre_get_posts filter via ajax call

You can apply a custom filter on your WP_Query that is on your ajax callback function like this: $my_query = apply_filters(‘my_plugin_pre_get_posts’, (new WP_Query($args))); Now you can use your existing pre_get_posts function for ajax calls also, add_action(‘pre_get_posts’, ‘myplugin_filter_posts’); // For All WP_Query instances add_filter(‘my_plugin_pre_get_posts’, ‘myplugin_filter_posts’); // For ajax function myplugin_filter_posts($query) { if (defined(‘DOING_AJAX’) && DOING_AJAX) { … Read more