在Wordpress上使用短代码

问题描述:

iam最近下载一个叫做The Gossip的Wordpress主题,这个主题有一个简码功能,可以帮助你创建不同的东西,例如让我们说我想显示类别小工具中的最后5个帖子我的侧边栏,所有这些我所要做的,就是要粘贴代码在Wordpress上使用短代码

[posts cats="gadgets" images="true" image_width="80" image_height="80" title="true" per_page="5" cols="1" image_wrap="true" pagination="false" meta="false" read_more="false" title_size="14" name='"sidebardog" content="post" content_display="excerpt" excerpt_length="0" spacing="spacing-small"] 

与主题没有休息,我的问题是,如何才能使一个代码从同一类别显示在过去的5帖目前的职位。我试图替换cats =“gadgets” for cats =“the_category();”cats =“”但它没有奏效。

任何人有关于如何正确地做到这一点的任何想法?非常感谢关注,任何帮助将不胜感激!

在functions.php中你会发现下面一行:

add_shortcode('posts', 'YOUR_SHORTCODE_FUNCTION_NAME'); 

,那么你只需要寻找YOUR_SHORTCODE_FUNCTION和里面使用全局$后变量

得到类别