dongxi5494 2016-08-30 09:41
浏览 47
已采纳

使用Wordpress中的Widget Logic插件在特定页面中显示小部件

I am trying to show a widget only in specific pages with Widget Logic plugin in Wordpress but i cant make it work in both (Line2 and Line3) situations. If I try each part of the code is working great.

$cats = array('test1','test2','test3');
global $post; return (in_array(1317, get_post_ancestors($post))) || is_tax('categories', $cats);
global $post; return is_single() && has_term($cats, 'categories', $post->ID);
  • 写回答

1条回答 默认 最新

  • dreamact3026 2016-08-30 10:41
    关注

    OK I added an if and working fine now in both situations...

    $cats = array('test1','test2','test3');
    global $post;
    if ((in_array(1317, get_post_ancestors($post)))) || is_tax('categories', $cats)) {
    return true;
    }
    elseif (is_single() && has_term($cats, 'categories', $post->ID)) {
    return true;
    }
    else return false;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog