Check if pods taxonomy has terms

I have a pods “newsroom” and a related taxonomy “newsroom_category”. Within the ‘newsroom_category”, I currently have 3 fields: “media”, “press_release”, “others”.

When a post is viewed, they’d see the type / term it belongs to. The type / term can be clicked to display the rest of the posts that belongs to it. So I have created a taxonomy-newsroom_category.php.

I currently have the script as below. But so far it’s not even displaying my “else” statement.

// The Query
//$query = new WP_Query( $args );

// Your custom code

$type = $_GET[‘type’];

$args = array(
‘post_type’ => ‘newsroom’,
‘post_per_page’ => -1,
‘relation’ => ‘AND’

// Added to test display
echo $type;

if($type != “”) {
$args[‘tax_query’][] = array(
‘taxonomy’ => ‘newsroom_category’,
‘field’ => ‘slug’,
‘terms’ => $type

$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
echo ‘<ul>’;
while ( $the_query->have_posts() ) {
$id = get_the_ID(); // with post id, you can get whatever you want.
echo ‘<li>’ . get_the_title() . ‘</li>’;
echo “hello”;
} //end while
echo ‘</ul>’;
/* Restore original Post Data */
} else {
// no posts found
echo “There’s nothing to display.”;

I hope someone can help as I’ve been stuck with this for awhile now. Thanks in advance.

Read more here:: Check if pods taxonomy has terms

Leave a Reply

Your email address will not be published. Required fields are marked *