This snippet shows all terms within the custom taxonomy 'state'. This snippet is in my taxonomy.php. I'd like to hide all the terms that don't have the same term as the current term page being viewed.

$terms = get_terms( array(
    'taxonomy' => 'state',
    'hide_empty' => true,
) );

$sep = '';
foreach ( $terms as $term ) {
    if( ++$count > 60 ) break;   // number of tags here.
    echo $sep . '<a href="'.get_term_link($term).'?suburb=armadale">'.$term->name.'</a>';
    $sep = ', ';  // Put your separator here.
  • Did you mean to hide terms that are not under the state taxonomy? – Jack Johansson Jan 4 '18 at 4:52
  • Not having the term the same as the current term of the current taxonomy.php – Pete Jan 4 '18 at 4:54

If you are on a term archive page, you already have the term object available to you via get_queried_object:

$term = get_queried_object();
echo get_term_link( $term );
echo $term->name;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.