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

custom post types - IfElse not working for header

programmeradmin0浏览0评论

I can't figure out why thisis not working. It works correctly if I just have 'events' but when I added 'guide' and 'firm-news' it doesn't changes those templates. I need to push then to H5 for SEO because we have multiple H1 tags on thousands of pages. Please help if you know what I'm doing wrong. Thank you!

    <?php //if is single event, guide, firm news
    if ( is_singular('events','guide','firm-news') ) : ?>
      <h5 class="event-subpage-header-title"><?php echo $title; ?></h5>
    <?php else : ?>
      <h1><?php echo $title; ?></h1>
    <?php endif; ?>

I can't figure out why thisis not working. It works correctly if I just have 'events' but when I added 'guide' and 'firm-news' it doesn't changes those templates. I need to push then to H5 for SEO because we have multiple H1 tags on thousands of pages. Please help if you know what I'm doing wrong. Thank you!

    <?php //if is single event, guide, firm news
    if ( is_singular('events','guide','firm-news') ) : ?>
      <h5 class="event-subpage-header-title"><?php echo $title; ?></h5>
    <?php else : ?>
      <h1><?php echo $title; ?></h1>
    <?php endif; ?>
Share Improve this question asked Nov 1, 2019 at 17:09 Naomi HarperNaomi Harper 1
Add a comment  | 

1 Answer 1

Reset to default 0

You actually doing mistake. You have to pass 3 parameters as array not like this. Use below code

<?php //if is single event, guide, firm news
    if ( is_singular( array('events','guide','firm-news') ) ) : ?>
        <h5 class="event-subpage-header-title"><?php echo $title; ?></h5>
<?php 
    else : 
?>
        <h1><?php echo $title; ?></h1>
<?php 
    endif; 
?>
发布评论

评论列表(0)

  1. 暂无评论