I have code in my header that excludes certain templates. I need to change it to also exclude an archive page for my Custom Post type. The file name for the archive template is taxonomy-press_category.php
.
But I don't know how to also include my custom post type archive template.
I am currently using:
if ( ! is_page_template ( array( 'homepage_template.php', 'services_template.php') ) )
CodePudding user response:
I highly recommend reading the "Docs" first. It'll help you get your question answered quicker!
"I need to change it to also exclude an archive page for my Custom Post type"
To exclude an archive page you could use !is_archive()
and !is_post_type_archive()
. To include it, then remove the !
.
and
if (is_post_type_archive('name-of-your-custom-post-type')){
// Write your code
}
Since you mentioned something about taxonomy, although it was not clear, is_tax()
could be another conditional check that might be useful.
Again I highly recommend reading the "Docs", or at least, include the details of your problem in a clear way so that people could help you faster.
CodePudding user response:
Thank you so much for your references, that helped.
This is the code that finally worked for me:
if( !is_page_template ('homepage_template.php') && !is_page_template( 'services_template.php' ) && !is_tax( 'press_category' )) {