Title: Conditional Tags Shortcode
Author: shazdeh
Published: <strong>2015 年 1 月 28 日</strong>
Last modified: 2020 年 5 月 26 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/conditional-tags-shortcode.svg)

# Conditional Tags Shortcode

 作者：[shazdeh](https://profiles.wordpress.org/shazdeh/)

[下载](https://downloads.wordpress.org/plugin/conditional-tags-shortcode.zip)

 * [详情](https://cn.wordpress.org/plugins/conditional-tags-shortcode/#description)
 * [评价](https://cn.wordpress.org/plugins/conditional-tags-shortcode/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/conditional-tags-shortcode/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/conditional-tags-shortcode/#developers)

 [支持](https://wordpress.org/support/plugin/conditional-tags-shortcode/)

## 描述

With this shortcode you can take control of where the content is displayed.

#### Usage

You can use all the [conditional tags](https://codex.wordpress.org/Conditional_Tags)
WordPress provides. Checkout examples below.

Show text only on the homepage:
 [if is_front_page] The text [/if]

Show text only on the About page of the site:
 [if is_page=”about”] The text [/if]

Show only on the category archive view:
 [if is_category] The text [/if]

You can add “not_” before the conditional tag to reverse the logic, example:
 Show
on all pages of the site except the homepage: [if not_is_front_page] The text [/
if]

#### OR

Using multiple parameters, the content is displayed when either of the conditions
are met (“OR” comparison), for example, show text on both category and tag archive
pages:
 [if is_category is_tag] The text [/if]

#### AND

To set multiple conditions you can nest the shortcode, for example show text only
on homepage AND if the user is logged in:
 [if is_user_logged_in][if is_front_page]
The text [/if][/if]

Show a link to wordpress.org site, only on single post pages and only on mobile 
devices:
 [if wp_is_mobile][if is_single] [WordPress](https://wordpress.org/) [/
if][/if]

#### has_term_{taxonomy}

You can use this to check if the current post in the loops belongs to a custom term
in the desired taxonomy. See: https://codex.wordpress.org/Function_Reference/has_term

Example, check if current post has the “jazz” term in the “genre” taxonomy:
 [if
has_term_genre=”jazz”] The text [/if]

## 安装

 1. Upload the `menu-item-visibility` directory to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Enjoy!

## 评价

![](https://secure.gravatar.com/avatar/a790366fa6c15cb32ce4b1d394966884f896da397176b9df63af01430867f816?
s=60&d=retro&r=g)

### 󠀁[Brilliant](https://wordpress.org/support/topic/brilliant-591/)󠁿

 [Tina Hammar](https://profiles.wordpress.org/tina-hammar/) 2016 年 9 月 3 日

Such a clever solution to create the code in a way that it doesn’t need to be updated
as it will accept all the conditional tags that wordpress provides. It will work
as long as wordpress don’t change their syntax …

 [ 阅读所有2条评价 ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/)

## 贡献者及开发者

「Conditional Tags Shortcode」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ shazdeh ](https://profiles.wordpress.org/shazdeh/)

[帮助将「Conditional Tags Shortcode」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/conditional-tags-shortcode)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/conditional-tags-shortcode/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/conditional-tags-shortcode/)，或
通过[RSS](https://plugins.trac.wordpress.org/log/conditional-tags-shortcode/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/conditional-tags-shortcode/)。

## 额外信息

 *  版本 **0.2**
 *  最后更新：**6 年前**
 *  活跃安装数量 **100+**
 *  WordPress 版本 ** 3.1 或更高版本 **
 *  已测试的最高版本为 **5.4.19**
 *  语言
 * [English (US)](https://wordpress.org/plugins/conditional-tags-shortcode/)
 * 标签
 * [conditional](https://cn.wordpress.org/plugins/tags/conditional/)[conditional-tags](https://cn.wordpress.org/plugins/tags/conditional-tags/)
   [context](https://cn.wordpress.org/plugins/tags/context/)[page](https://cn.wordpress.org/plugins/tags/page/)
   [shortcode](https://cn.wordpress.org/plugins/tags/shortcode/)
 *  [高级视图](https://cn.wordpress.org/plugins/conditional-tags-shortcode/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  2 条 5 星评价     ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/conditional-tags-shortcode/reviews/)

## 贡献者

 *   [ shazdeh ](https://profiles.wordpress.org/shazdeh/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/conditional-tags-shortcode/)