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 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?