城市简码
Recently, we got a request from a user asking how they could use WordPress shortcodes in their WordPress themes. Shortcode is a special tag that you can enter into a post that gets replaced with different content when actually viewing the post on the website. If you have ever embedded a WordPress gallery on your blog, then you’ve already seen the built in shortcode. Check out our article on adding shortcodes in your themes.
最近,我们收到用户的询问,询问他们如何在WordPress主题中使用WordPress短代码。 简码是一个特殊标签,您可以输入一篇帖子,当在网站上实际查看该帖子时,该帖子将替换为其他内容。 如果您曾经在博客上嵌入WordPress画廊,那么您已经看到了内置的简码。 查阅我们有关在主题中添加简码的文章。
Thankfully, WordPress has a very easy function called do_shortcode() that lets you add shortcodes in your themes. Simply add the code like this:
值得庆幸的是,WordPress具有一个非常简单的函数do_shortcode() ,可让您在主题中添加短代码。 只需添加如下代码:
<?php echo do_shortcode("[example_shortcode]"); ?>
Simple and easy
简单容易
翻译自: https://www.wpbeginner.com/wp-themes/how-to-use-shortcodes-in-your-wordpress-themes/
城市简码