默认情况下,WordPress不会在小部件或文章摘要中执行短代码(short code)。 要将短代码插入文本小部件和/或摘录中,您需要在functions.php中添加以下代码:
复制以下代码粘贴到functions.php
//Enable Shortcodes in WordPress Excerpts and Text Widgets. Add to functions.php add_filter('the_excerpt', 'do_shortcode'); add_filter('widget_text', 'do_shortcode');
将以上代码直接复制粘贴到你的主题functions.php的最末端即可。(functions.php在外观——主题编辑器——右侧找到functions.php)
请确保使用子主题来添加此代码。如果不是,当你更新你的主题时代码将被擦除。
记住,对主题做修改时尽量使用子主题!