A set of shortcodes for the website administrators.
网站管理员的一组短代码。 p>
if
如果 h4>
Using this shortcode you can limit the display of the text or shortcodes to specific page(s) on your website.
使用此简码,您可以将文本或简码的显示限制为网站上特定页面的显示。
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>
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>
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>
switch_to_blog
switch_to_blog h4>
Run shortcodes in the context of another website in the network.
在网络中另一个网站的上下文中运行简码。
This shortcode is only available in multisite installations (WP Network).
此短代码仅在多站点安装(WP网络)中可用。
For example, list posts from another blog:
例如,列出另一个博客的帖子:
[switch_to_blog id=”10″] [list_posts limit=”10″] [/switch_to_blog]
[switch_to_blog id =” 10”] [list_posts limit =“ 10”] [/ switch_to_blog] p>
iterator
迭代器 h4>
Display text or shortcodes only if repeated a certain number of times.
仅在重复一定次数后才显示文本或简码。
Requires an “id” parameter which should be unique for that shortcode (can be anything you want).
需要一个“ id”参数,该参数对于该短码应该是唯一的(可以是您想要的任何东西)。
[iterator id=”my-ads” repeat=”5″] My ad codes [/iterator]
[iterator id =“ my-ads” repeat =“ 5”]我的广告代码[/ iterator]
After every 5th call to that shortcode, render the output.
在第5次调用该短代码后,呈现输出。 p>
get_template
get_template h4>
Load a template file into the page.
将模板文件加载到页面中。
The referenced file is loaded from child theme if it exists, if not from the parent theme.
如果存在子主题,则从子主题加载引用的文件;如果不存在,则从父主题加载。
Example, load includes/slider.php template file from the theme:
例如,从主题加载include / slider.php模板文件:
[get_template slug=”includes/slider”]
[get_template slug =” includes / slider”] p>
scheduler
调度程序 h4>
Show text or shortcodes only if the specified date has passed.
仅在指定的日期过去后才显示文本或简码。
Example, show the text only if it’s after Christmas of 2016:
例如,仅在2016年圣诞节后显示文本:
[scheduler date=”December 25, 2016″] Text [/scheduler]
[scheduler date =” 2016年12月25日”]文本[/ scheduler] p>
date
日期 h4>
Shows the current date or time in the specified format (https://codex.wordpress.org/Formatting_Date_and_Time).
以指定的格式(https://codex.wordpress.org/Formatting_Date_and_Time)显示当前日期或时间。
Uses Date Format (in Settings > General) by default.
默认使用日期格式(在“设置”>“常规”中)。
[date format=”F j, Y”]
[日期格式=“ F j,Y”] p>
loginoutlink
loginoutlink h4>
Display a link to login page if user is not logged-in, or a logout page if they are.
如果用户未登录,则显示指向登录页面的链接,如果用户未登录,则显示退出页面。
Parameters:
参数: p>
- login : “Log in” text
- 登录:“登录”文本 li>
- logout : “Log out” text
- 注销:“注销”文本 li>
- redirect : optional URL to redirect to on login or logout
- redirect:登录或注销时重定向到的可选URL li>
ul>
login_form
login_form h4>
Display the login form.
显示登录表单。 p>
custom_field
custom_field h4>
Display a custom field from a post.
显示帖子中的自定义字段。
Parameters:
参数: p>
ul>
disable
禁用 h4>
Wrap any content or shortcode with [disable]
shortcode to prevent that piece of content from being rendered.
使用 [disable] code>短码包装任何内容或简码,以防止呈现该段内容。Perfect for debugging shortcodes.
非常适合调试简码。 p>
the_id
the_id h4>
Shows the current post ID;
显示当前帖子ID;
useful when you need to debug WP Loops.
在需要调试WP循环时很有用。 p>
Path shortcodes
路径短代码 h4>
[home_url] : returns the homepage URL
[home_url]:返回主页URL
[get_template_directory] : Absolute path to the parent theme directory
[get_template_directory]:父主题目录的绝对路径
[get_template_directory_uri] : URL to the directory of the parent theme
[get_template_directory_uri]:父主题目录的URL
[get_stylesheet_directory] : Absolute path to the directory of the child theme
[get_stylesheet_directory]:子主题目录的绝对路径
[get_stylesheet_directory_uri] : URL to the directory of the child theme
[get_stylesheet_directory_uri]:子主题目录的URL p>
rand shortcodes
rand短代码 h4>
Show a random number between two numbers.
显示两个数字之间的随机数。
Parameters:
参数:
* min : minimum value (default 0)
* min:最小值(默认为0)
* max : maximum value (default 100)
* max:最大值(默认100) p>