admin管理员组

文章数量:1023263

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

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

Share Improve this question edited May 11, 2019 at 0:02 fuxia 107k39 gold badges255 silver badges459 bronze badges asked May 10, 2019 at 23:53 HenryHenry 9831 gold badge8 silver badges31 bronze badges 1
  • * I tested it and it works fine. I just want to be sure and learn. Thanks – Henry Commented May 10, 2019 at 23:58
Add a comment  | 

1 Answer 1

Reset to default 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.

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

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

Share Improve this question edited May 11, 2019 at 0:02 fuxia 107k39 gold badges255 silver badges459 bronze badges asked May 10, 2019 at 23:53 HenryHenry 9831 gold badge8 silver badges31 bronze badges 1
  • * I tested it and it works fine. I just want to be sure and learn. Thanks – Henry Commented May 10, 2019 at 23:58
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: Can I add other Custom Taxonomy to my syntax (functionsphp)