With this shortcode you can take control of where the content is displayed.
使用此短代码,您可以控制内容的显示位置。 p>
Usage
用法 h4>
You can use all the conditional tags WordPress provides.
您可以使用WordPress提供的所有条件标记。
Checkout examples below.
下面的结帐示例。 p>
Show text only on the homepage:
仅在首页上显示文本:
[if is_front_page] The text [/if]
[if is_front_page]文本[/ if] p>
Show text only on the About page of the site:
仅在网站的“关于”页面上显示文本:
[if is_page=”about”] The text [/if]
[if is_page =“ about”]文本[/ if] p>
Show only on the category archive view:
仅在类别归档视图中显示:
[if is_category] The text [/if]
[if is_category]文本[/ if] p>
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] p>
OR
OR h4>
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] p>
AND
AND h4>
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] p>
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] p>
has_term_{taxonomy}
has_term_ {分类法} h4>
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 p>
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] p>