How to sort by multiple values in a nested WP_Query
How to sort by multiple values in a nested WP_Query
How to sort by multiple values in a nested WP_Query
try this <?php $new=new WP_Query(array(‘posts_per_page’=> 1,’order_by’=>’DESC’)); $max_id; if($new->have_posts()){ while($new->have_posts()) { $new->the_post(); $max_id=the_id(); } } echo $max_id;
Try this static function loop_args($parent_id, $number) { $today = getdate(); $args = [ ‘cat’ => $parent_id, ‘showposts’ => ‘7’, ‘orderby’ => ‘ID’, ‘order’ => ‘asc’, ‘date_query’ => array( array( ‘year’ => $today[“year”], ‘month’ => $today[“mon”], ‘day’ => $today[“mday”], ), ), ]; return $args; }
wp query search multi terms
You have a couple hurdles to handle … 1) You can have multiple Category codes for each post, so they are not normal query variables (not really a hurdle – but you may get repeat occurrances of the same post under multiple categories). 2) Category titles are 1 linkage ‘further’ away (in terms of SQL … Read more
Filter posts by their related field’s custom field
You can do it with WOOT: https://products-tables.com/shortcode/woot/ – create 2 tables in admin panel and set predefinitions in their settings https://c2n.me/48YmMqO.png Then create in file functions.php your own shortcode, where depending of the user logged-in or not, show one of the [woot] tables
Get categories within specific term
Use a meta query. Since ACF stores dates as Ymd you can just treat the value as a number: $date_query = array( ‘key’ => ‘start_date’, // ACF date field name ‘type’ => ‘NUMERIC’, ‘value’ => ‘20200101’, ‘compare’ => ‘<=’, // All posts with start date before/on January 1st 2020 ); $args[‘meta_query’] = array( $date_query ); … Read more
You can use meta_query property when fetching post data using new WP_Query() $vehicles = new WP_Query([ ‘post_type’ => ‘vehicle’, ‘meta_query’ => [ ‘relation’ => ‘AND’, [ ‘key’ => ‘wheel’, ‘value’ => ‘4’, ], [ ‘key’ => ‘color’, ‘value’ => ‘blue’, ] ]); WP_Query official docs