Thread Starter
leelnj
(@leelnj)
Hi. Thanks for that but if possible could you help further please
I have three custom post types. News, sport and lifestyle. How will i select those in the filter query function below and once i enter the query what post type will i select in the backend
<?php
add_filter(‘dd_carousel_filter_query_args’, ‘filter_carousel’, 10, 2);
function filter_carousel($args, $carouselID){
if ($carouselID == 9803){
$args = array(
‘post_type’ => array( ‘post’ ),
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘_chosen_store’,
‘value’ => ‘1’,
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
),
);
return $args;
}
}
Using standard WP_Query arguments.
'post_type' => array('news', 'sport', lifestyle')
Thread Starter
leelnj
(@leelnj)
Hi sorry to bother you again. I have entered the post types slugs according to what i entered in custom post type ui. I have changed the carousel id number. It is not working. Is there anything you can see which im doing wrong. thanks in advance.
add_filter(‘dd_carousel_filter_query_args’, ‘filter_carousel’, 10, 2);
function filter_carousel($args, $carouselID){
if ($carouselID == 161){
$args = array(
‘post_type’ => array( ‘reveals’, ‘refresh’, ‘retreat’, ‘Reauses’ ),
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘_chosen_store’,
‘value’ => ‘1’,
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
),
);
return $args;
}
}
Well if you don’t need the meta query… take it out.
You could try using this to generate your query args: https://generatewp.com/wp_query/
Since there are no additional questions, I’m marking this as resolved.