• I have a custom taxonomy called country, which is associated with certain posts with terms like “India”, “US”, “UK” etc.

    Now I want to retrieve all posts that belong to the “country” taxonomy, irrespective of which term (“India”, “US” etc) they have.

    Is it possible to do it or do I have to write a custom SQL query to retrieve it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • see this sample

    $args = array(
    	'tax_query' =>
    		'relation' => 'AND',
    		array(
    			'taxonomy' => 'movie_janner',
    			'field' => 'slug',
    			'terms' => array( 'action', 'commedy' ),
    		),
    		array(
    			'taxonomy' => 'actor',
    			'field' => 'id',
    			'terms' => array( 103, 115, 206 ),
    			'operator' => 'NOT IN',
    		)
    )
    query_posts( $args );
    Thread Starter Sudar Muthu

    (@sudar)

    In the doc it is specified that “Multiple Taxonomy Handling” is available only from WordPress 3.1.

    I want something which can work in the current version of WordPress.

    try this query_posts( array('country') ); or thisquery_posts( array('country' => array("India", "US", "UK")) );

    Thread Starter Sudar Muthu

    (@sudar)

    query_posts( array('country') ); doesn’t work.

    query_posts( array('country' => array("India", "US", "UK")) );

    I cannot use this query, because there are lot of terms and I cannot list all of them.

    may be it will help query_posts('taxonomy'=> 'country');

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get all posts from a taxonomy’ is closed to new replies.