0

I am using this syntax to remove excerpts on Custom Taxonomy archive listings and it works great:

add_filter( 'excerpt_length','remove_excerpt', 1000 );
function remove_excerpt( $length ) 
{
    if ( is_tax('country') ) {
        return 0;
    } 
    return $length;
}

However, I also have two other Custom Taxomoies....

Is this correct to add the other two like this?

add_filter( 'excerpt_length','remove_excerpt', 1000 );
function remove_excerpt( $length ) 
{
    if ( is_tax('country') ) {
        return 0;
    } 
    elseif ( is_tax('us_state') ) {
        return 0;
    } 
    elseif ( is_tax('cities') ) {
        return 0;
    } 
    return $length;
}

I want the same result for all three...

Just want to make sure I am doing it correctly.

Thanks

1
  • * I tested it and it works fine. I just want to be sure and learn. Thanks
    – Henry
    May 10, 2019 at 23:58

1 Answer 1

1

I believe you can also pass an array to is_tax:

if(is_tax(array('country', 'us_state', 'cities')) {
   return 0;
}

Give that a try, but otherwise what you have is fine.

2
  • Thanks. Would your solution save a tiny amount of time to execute? Just curious...
    – Henry
    May 11, 2019 at 0:44
  • Possibly, but we would be talking fractions of a second. It just makes the code a little neater more than anything - especially if you had 5 or 10 taxonomies to check. May 11, 2019 at 9:13

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.