[wordpress插件] Conditional Tags Shortcode条件标签简码

wordpress 插件 文章 2020-03-30 06:20 471 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

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

使用此短代码,您可以控制内容的显示位置。

Usage

用法

You can use all the conditional tags WordPress provides.

您可以使用WordPress提供的所有条件标记

Checkout examples below.

下面的结帐示例。

Show text only on the homepage:
    

仅在首页上显示文本:
    

[if is_front_page] The text [/if]

[if is_front_page]文本[/ if]

Show text only on the About page of the site:
    

仅在网站的“关于”页面上显示文本:
    

[if is_page=”about”] The text [/if]

[if is_page =“ about”]文本[/ if]

Show only on the category archive view:
    

仅在类别归档视图中显示:
    

[if is_category] The text [/if]

[if is_category]文本[/ if]

You can add “not_” before the conditional tag to reverse the logic, example:

您可以在条件标记之前添加“ not_”以反转逻辑,例如:

Show on all pages of the site except the homepage:
    

在网站的所有页面上显示,首页除外:
    

[if not_is_front_page] The text [/if]

[if not_is_front_page]文本[/ if]

OR

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:
    

使用多个参数,当满足两个条件中的任何一个(“ OR”比较)时,将显示内容,例如,在类别和标签归档页面上显示文本:
    

[if is_category is_tag] The text [/if]

[if is_category is_tag]文本[/ if]

AND

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]

[if is_user_logged_in] [if is_front_page]文本[/ if] [/ if]

Show a link to wordpress.org site, only on single post pages and only on mobile devices:
    

仅在单个帖子页面上和仅在移动设备上显示到wordpress.org网站的链接:
    

[if wp_is_mobile][if is_single] WordPress [/if][/if]

[if wp_is_mobile] [if is_single] WordPress [/ if] [/ if]

has_term_{taxonomy}

has_term_ {分类法}

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

请参阅: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]

[if has_term_genre =“爵士乐”]文本[/ if]

安装步骤

    1. Upload the menu-item-visibility directory to the /wp-content/plugins/ directory
    2. menu-item-visibility 目录上传到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Enjoy!
    6. 享受!

下载地址
https://downloads.wordpress.org/plugin/conditional-tags-shortcode.zip
-EOF-

AI助手支持GPT4.0