dsadsa123111 2013-12-03 16:33
浏览 36
已采纳

如果URL数组创建动态滑块,是否可以使用PHP?

My understanding of PHP is pretty basic so please forgive me if I don't use the correct terms, please ask for clarification if I do.

My ultimate goal is to create a slider that loads different sets of images depending on the URL, but some of the pages share the same images as others so I'd like to be able to share some images across multiple pages, using PHP to pull in the photos would save a lot of time editing each page seperatly.

I know I can use <?php if (is_page_template('homepage.php')) { ?> in Wordpress to specify an action on a particular page as long as it has a template. But needing lots of template files gets messy and leaves me with my original problem.

So is there something along the lines of <?php if (is_url('example.com/stuff')) { ?> that I could use instead?

And if so, is it possible to make it an array of url's? eg have more than one URL listed per command? I'm not quite sure on the syntax that would be required to do that.

I'll make an example to help you see where I'm going, but the syntax is probably way off.

EXAMPLE:

<div id="products">
 <div class="slides_container">
  <ul>
    <li>
      <?php if (is_url('example.com/stuff') || ('example.com/other-stuff')) { ?>
      <img src="images/picture.jpg" alt="Pretty Picture" />
      <?php } ?>
    </li>
  </ul>
 </div>
</div>

Help is greatly appreciated.

  • 写回答

2条回答 默认 最新

  • drqefnd544707688 2013-12-03 17:10
    关注

    I found the solution, on Google with the search "If Post ID"

    <?php if(is_page( array('about-me', 'About Me And Joe' ) ) { ?> <img src="picture.jpg" /> <?php } ?>
    

    Should do the trick, thank you for your help guys.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型