Answers for "wp query tax query"

PHP
0

wp tax query

//simple
'tax_query' => array(
    array(
        'taxonomy' => 'people',
        'field'    => 'slug',
        'terms'    => 'bob',
    ),
),

//more complicated
'tax_query' => array(
    'relation' => 'OR',
    array(
        'taxonomy' => 'category',
        'field'    => 'slug',
        'terms'    => array( 'quotes' ),
    ),
    array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'post_format',
            'field'    => 'slug',
            'terms'    => array( 'post-format-quote' ),
        ),
        array(
            'taxonomy' => 'category',
            'field'    => 'slug',
            'terms'    => array( 'wisdom' ),
        ),
    ),
),
Posted by: Guest on December-16-2020
5

wp query

<?php 
// The Query
$the_query = new WP_Query( $args );
 
// The Loop
if ( $the_query->have_posts() ) {
    echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
    echo '</ul>';
} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Posted by: Guest on September-27-2020
0

wp tax_query in

'tax_query' => array(
    array(
        'taxonomy' => 'video_type',
        'terms' => 'episode',
        'field' => 'slug',
        'include_children' => true,
        'operator' => 'IN'
    )
),
Posted by: Guest on June-04-2021

Browse Popular Code Answers by Language