【问题标题】:conditional statement if is_page for multiple pages in wordpress条件语句 if is_page 用于 wordpress 中的多个页面
【发布时间】:2017-01-09 06:44:33
【问题描述】:

我正在尝试使用 wordpress 中的 if is_page 条件语句按 ID 定位多个页面。这就是我所拥有的:

if ( is_page('222','223') ) {
        echo 'content for pages 222 and 223';
    }

但这仅适用于第一页

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    根据Wordpress documentation,is_page() 函数接受整数、字符串和数组。尝试传入 ID 的数组,如下所示:

    if(is_page([222,223])) { 
        echo 'content for pages 222 and 223';
        return true; 
    } else { 
        return false; 
    }
    

    【讨论】:

      猜你喜欢
      • 2011-03-23
      • 2022-06-28
      • 2020-12-29
      • 2023-01-12
      • 2015-01-20
      • 2013-12-17
      • 2012-02-04
      • 2022-12-26
      • 1970-01-01
      相关资源
      最近更新 更多