My theme has a title bar below the menu. The title bar displays the Title and a breadcrumbs menu. The code is in a template file called title-bar.php. The title bar now shows up on all pages and on all posts.
I want this title bar only to show up on all my custom post type archive pages, but hide it on all other pages and on all single posts including custom post types.
How can I do this?
IF page type is ARCHIVE: (code for title bar)
ELSE: (empty)
My theme has a title bar below the menu. The title bar displays the Title and a breadcrumbs menu. The code is in a template file called title-bar.php. The title bar now shows up on all pages and on all posts.
I want this title bar only to show up on all my custom post type archive pages, but hide it on all other pages and on all single posts including custom post types.
How can I do this?
IF page type is ARCHIVE: (code for title bar)
ELSE: (empty)
Share Improve this question asked Apr 7, 2020 at 21:53 HAL2020HAL2020 398 bronze badges1 Answer
Reset to default 1You can use is_post_type_archive()
, which is one of the many conditional tags in WordPress:
if ( is_post_type_archive( 'your_post_type' ) ) {
// show the title bar
}
// else, just do nothing