WP_query with ajax filter not working with input fields
WP_query with ajax filter not working with input fields
WP_query with ajax filter not working with input fields
functions with get_post_meta
You are right, in your current approach, WordPress does not natively support ordering by specific post types in WP_Query. However, you can still achieve what you’re looking for through a custom SQL clause. By using the posts_clauses filter, you can modify the SQL query before it’s executed. Please note that using custom SQL queries should … Read more
I have finally found a solution and for anyone interested, here is the working code : <?php // The Query if (is_tax() || is_category() || is_tag() ){ $qobj = $wp_query->get_queried_object(); // concatenate the query $args = array( ‘post_type’ => ‘houses’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more
The documentation for WP_Query indicates that ordering by meta value is limited to one meta key and requires the meta_key parameter (untested): $results = new WP_Query( array( ‘meta_key’ => ‘wpcf_catalogue_number’, ‘orderby’ => array( ‘meta_value_num’ => ‘ASC’, ), ) ); If you want additional sorting, you’ll need to sort the result ($results->posts) using PHP (untested): $sort__formats … Read more
If the date query doesn’t work because of modified post dates (e.g. if the posts’ timeline is no longer linear), here’s a posts_where filter’s suggestion (untested): add_filter( ‘posts_where’, function( $where, $query ) use ( &$wbdb ) { $id = $query->get( ‘_id__gt’ ); if( is_int( $id ) && $id > 0 ) { $where .= $wpdb->prepare( … Read more
I believe you could use NOT IN for the operator to achieve this along with switching some of the relations from ORs to ANDs. array ( ‘taxonomy’ => ‘plant_category’, ‘field’ => ‘name’, ‘terms’ => ‘Popular (home)’, ‘operator’ => ‘NOT IN’, ),
get_meta_sql hook is not firing
Ok, I think your iterations were off… You start the count at 0, so while you have the posts from 1 o 7 in the picture, you’re actually working with 0 to 6. So I re-wrote it with greater than and less than comparisons in the if and elseif conditions. <?php function three_column_sc($atts){ ob_start(); ?> … Read more
The simplest solution is to get all the existing rewrite rules, match the requested URl to one of them, and then convert it into a query. Like so: // Get all the rewrite rules global $wp_rewrite; $url_path = “2020/04/test-post”; // Or “tag/whatever” or “feed/atom” etc // Match the URL against WordPress rewrite rules $rewrite_rules = … Read more