[WP插件]Widget Logic|自定义侧边栏只显示在首页或内页显示

前言:
众所周知,WP 的侧边栏 widgets 小工具是全局的,后台添加后,无论是首页,内页,都会显示。
一般的WPer喜欢直接修改 theme 下的 sidebar.php ,添加诸如 if(!is_home())这样的条件判断来控制输出。
HzlzH就是一直这样干的,但是为了后期管理方便,我还是装了个插件:Widget Logic。

以前,我介绍过 本站使用的 20个 wordpress插件汇总,如今需要多添加上这个插件了,共21个啦,所以另开帖介绍一下!

插件名:Widget Logic
作者:Alan Trewartha
官方下载地址:http://wordpress.org/extend/plugins/widget-logic/

使用方法:
1、下载–安装–启用

2、点击 [外观]—[小工具]—[选择要设置逻辑的侧边栏],会发现(图1)这样的框格,填写相应逻辑代码即可。

widget_logic

例如:

is_home() home页
is_front_page() 首页 
is_search() 搜索结果页 
is_feed() 订阅feed
is_admin() 如果是管理员 
is_single() 文章is_archive() 归档页 
is_404() 404错误页面
is_page() 页面
is_category() 分类页 
is_tag() 标签页 

在 前面加 ! 就是除此之外的意思,比如  !is_home()  就是处了主页都显示。

应用:

1、友情链接只在首页显示;     N年前的方法!

2、侧边栏广告位只在文章页面显示;

3、Twi-t-ter timeline 只在 page级页面调用,文章不调用;等等

版权所有© HzlzH | 本文采用 BY-NC-SA 进行授权
转载需注明 转自: 《[WP插件]Widget Logic|自定义侧边栏只显示在首页或内页显示

相关文章

{ Leave a Reply ? }

  1. evlos Netherlands Google Chrome Windows

    嘿嘿,沙发一下 ~ :mrgreen:

  2. littlebear Canada Mozilla Windows

    打字打错了, 处了? 应该是”除”了. :) :wink:

  3. 一米 China Internet Explorer Windows

    还是喜欢全局的,现在插件已经很多了,不敢再加了啊。

  4. HillBoy China Maxthon Windows

    恩,这个插件一直在用了。

  5. 帅哥 China Google Chrome Windows

    我的主题不支持widget,只得编辑sidebar,不过想在内页显示的还是会编辑文件而不用插件,插件装的够多了。。

  6. 易棋牌 China Internet Explorer Windows

    4楼的看得还真仔细! :)

  7. sleepy China Google Chrome Windows

    实现这个功能好像不太需要插件的吧

  8. Dianso China Google Chrome Windows

    侧边我什么都不想放,要不是有些链接,我都想删除掉侧边了。。

  9. Ray Chow China Google Chrome Windows

    我用 Samsarin PHP Widget 可以在侧边栏写入代码

  10. Firm China Google Chrome Windows

    这个插件很方便,我也用上了
    :mrgreen:

  11. forging China 360 Browser Windows

    感谢博主分享.学习了

  12. zwwooooo China Opera Windows

    懒人插件,好

  13. 郑州SEO China Internet Explorer Windows

    朋友 文章页面的 分类目录怎么提取的 我的博客我提取了 但带上了a标签 怎么去掉呢 能告知一下吗

      • 郑州seo China Internet Explorer Windows

        @HzlzH,对的,你看到文章title了吧,怎么去掉这个a标签呢,在网上找了方法都没去掉,等待你的回复,我的qq:37996619

  14. Louis Han China Mozilla Firefox Windows

    非常简单实用的方法

  15. 皓辰 China Internet Explorer Windows

    嗯,一般我都愿意使用if

  16. 绍兴小杜 China Google Chrome Windows

    呵呵,这个插件不错

  17. 严重浪漫 China Internet Explorer Windows

    这个超级好,一定要支持

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)

Pingback & Trackback

  1. Tweets that mention [WP插件]Widget Logic|自定义侧边栏只显示在首页或内页显示 | 自力博客 -- Topsy.com United States Unknow Browser Unknow Os - Pingback on 2010/04/30/ 08:06