• Resolved jpvanmuijen

    (@jpvanmuijen)


    Hi (not sure if this is the right forum),

    I have a custom taxonomy (called Term), which means a post or page can have multiple terms attached to it.
    I would like to query other post types using these terms.

    So first, I get the terms for the current page:
    $terms = wp_get_object_terms($post->ID, 'term');

    Next, I query child pages of a certain page ID, trying to find pages with one or more matching terms:

    $args = array(
    			'post_type' => 'page',
    			'post_parent' => 265,
    			'tax_query' => array(
    				'relation' => 'OR',
    				array(
    					'taxonomy' => 'term',
    					'field' => 'slug',
    					'terms' => array($terms)
    				)
    			)
    		);
    		$loop = new WP_Query( $args );
    
    		while ( $loop->have_posts() ) : $loop->the_post();

    Etc.

    I can echo the values of $terms using a foreach loop, but no luck using those values in the tax_query.

    Any ideas on how to achieve this?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use wp_get_object_terms result in tax_query’ is closed to new replies.