You can set a conditional argument for multiple custom post types in WordPress using in_array

The format is like so…

if( in_array( get_post_type(), array( 'treatment', 'package' )) ) {//add in cpts here
// do stuff
 }
 else { //what all the other post types get
// do other  stuff
}
 }

It searches the array of cpts to see if they belong to the value, which is the function get_post_type() – which they do, and returns true.

So altering the read more excerpt would be like…

View the code on Gist.

To target the archive pages for multiple custom post types you can use is_post_type_archive

if ( is_post_type_archive( array( 'portfolio', 'testimonial' )) {

// do stuff

}

 

Share:

Leave a Reply