最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Show title bar only on archiveshide it on all posts and pages

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

You 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
发布评论

评论列表(0)

  1. 暂无评论