【问题标题】:Multiple thumbnails in WordPress based on page template?WordPress中基于页面模板的多个缩略图?
【发布时间】:2012-11-18 23:49:31
【问题描述】:

有没有办法根据页面模板或页面 ID 在页面中添加多个缩略图 而不是帖子类型(帖子、页面)?

【问题讨论】:

    标签: wordpress thumbnails


    【解决方案1】:

    您可以添加条件语句来测试特定的页面 id:

    if(is_page('<your page id>')){
        // Do your thing
    }
    

    同样,您可以像这样测试特定的页面模板:

    if(is_page_template('<page template file name>']){
       // Go on wit' you bad self
    }
    

    确保在使用 is_page_template() 时向其提供模板的文件名,例如 is_page_template('two-columns.php'),而不是模板的名称,例如 is_page_template('Two Columns')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多