I'm trying to pull custom post types that have a specific custom taxonomy
This is what i've tried:
$args = array(
'posts_per_page' => -1,
'post_type' => 'products',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'subjects',
'field' => 'name',
'terms' => $shortcode_atts['subject'],
),
array(
'taxonomy' => 'plans',
'field' => 'name',
'terms' => $shortcode_atts['plan'],
),
),
);
$shortcode_atts looks like this:
string(80) "Array
(
[subject] => אינטרנט
[plan] => מסלול 10 גיגה
)
"
i.e. That's in Hebrew, subject=internet and plan=10giga
I also tried to use operator, wasn't sure in which place to add it so I tried in all locations but it didn't work. Can someone guide me how to pull these posts?
This query returns all cpt's without the filtering that I want.
EDIT: shortcode_atts is this:
function show_product( $atts, $content = null, $tag ) {
$shortcode_atts = shortcode_atts( array(
'subject' => '',
'plan' => ''
), $atts );
}
add_shortcode( 'show_product', 'show_product' );
Thanks!
$shortcode_atts
is a string. It should be an array. Can you include more of where you're setting it.$atts['subject']
and$atts['plan']
? the documentation for this method isn't so good.var_dump( $args )
and show what you get.$args
. Just the arguments, before you do the query.