【问题标题】:Different Item Active for Bootstrap Carousel on each page每个页面上为引导轮播激活的不同项目
【发布时间】:2015-05-20 16:59:28
【问题描述】:

我正在使用带有来自 twitter 的引导程序的 wordpress。我想为轮播的每个页面使用不同的活动项目。

例如:当页面 is_page('Kontakt') 时,轮播中活动的项目不应该是第一张图片,而是第二张。

代码:

 <div class="item active">
  <img src="http://testserver.webdesign-solution.net/sonnenhof-hotel/wp-content/uploads/2015/05/header-bild.png" alt="Chania">
</div>

<div class="item">
  <img src="http://testserver.webdesign-solution.net/sonnenhof-hotel/wp-content/uploads/2015/05/header-bild2.png" alt="Flower">
</div>

我该如何解决?

【问题讨论】:

    标签: javascript php jquery wordpress twitter-bootstrap


    【解决方案1】:

    为什么不使用 is_page() wordpress 函数?

    <div class="item <?php if ( is_page('Kontakt') ) { echo "active"; } ?>">
      <img src="http://testserver.webdesign-solution.net/sonnenhof-hotel/wp-content/uploads/2015/05/header-bild.png" alt="Chania">
    </div>
    
    <div class="item <?php if ( is_page('xxxxxxx') ) { echo "active"; } ?>">
      <img src="http://testserver.webdesign-solution.net/sonnenhof-hotel/wp-content/uploads/2015/05/header-bild2.png" alt="Flower">
    </div>
    

    【讨论】:

    • 谢谢,这很有帮助,但它不能正常工作。我只需要 4 个站点的自定义标题。其他人应该激活标准项目。
    猜你喜欢
    • 2017-05-13
    • 2015-08-09
    • 2023-03-22
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多