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

custom post types - I'm trying to create an if statement that will only display my button link for tickets if its under

programmeradmin3浏览0评论

<!-- column links -->
    <div class="col-md-3 offset-md-2 links">
    <?php  if ( is_category( 'admission-event' ) ) { ?>

      <a href="/" title="<?php the_title();?>" class="btn btn-secondary tickets" <?php echo $open_new_window; ?>>BUY TICKETS</a>

      <a href="<?php echo $post_link  ?>" title="<?php the_title();?>" class="btn btn-secondary more-info" <?php echo $open_new_window; ?>>MORE INFO<i class="fa fa-angle-right"></i> </a>

    <?php } else { ?>

      <a href="<?php echo $post_link  ?>" title="<?php the_title();?>" class="btn btn-secondary more-info" <?php echo $open_new_window; ?>>MORE INFO<i class="fa fa-angle-right"></i> </a>

    <?php } ?>
    </div>
    <!-- /column links -->



<!-- column links -->
    <div class="col-md-3 offset-md-2 links">
    <?php  if ( is_category( 'admission-event' ) ) { ?>

      <a href="https://www.eventbrite/d/ut--salt-lake-city/vocalocity/" title="<?php the_title();?>" class="btn btn-secondary tickets" <?php echo $open_new_window; ?>>BUY TICKETS</a>

      <a href="<?php echo $post_link  ?>" title="<?php the_title();?>" class="btn btn-secondary more-info" <?php echo $open_new_window; ?>>MORE INFO<i class="fa fa-angle-right"></i> </a>

    <?php } else { ?>

      <a href="<?php echo $post_link  ?>" title="<?php the_title();?>" class="btn btn-secondary more-info" <?php echo $open_new_window; ?>>MORE INFO<i class="fa fa-angle-right"></i> </a>

    <?php } ?>
    </div>
    <!-- /column links -->


Share Improve this question asked Dec 2, 2019 at 3:19 AddyAddy 1 3
  • Can use please try with in_category('admission-event') instead of is_category('admission-event'); – Gopala krishnan Commented Dec 2, 2019 at 10:15
  • I’ll try that! Thank you so much for your help. It’s greatly appreciated – Addy Commented Dec 3, 2019 at 10:27
  • Have you got solution for that? – Gopala krishnan Commented Dec 3, 2019 at 10:28
Add a comment  | 

1 Answer 1

Reset to default 0

is_category() is the wrong function to use here. That category is checking Are we on the archive page for the given category?

The correct function to use would be has_category(), which is checking Is this post in the given category?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论