在 wordpress 主题中启用短代码 [英] Enable shortcodes in a wordpress theme

查看:31
本文介绍了在 wordpress 主题中启用短代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从头开始为 wordpress 3.3.1 开发了一个新主题,但短代码不起作用.到目前为止,我一直在搜索,这是过滤包含短代码的内容的问题,过滤器代码添加到主题特定位置(shorcodes 正在与另一个主题一起使用).所以,我的问题是:启用通用短代码主题的代码是什么?

I develop a new theme for wordpress 3.3.1 from scratch and shortcodes are not working on it. As I searched until now it is a matter of filtering the content containing the shortcode, filter code added in a theme specific location(shorcodes are working with another theme). So, my question is : What is the code for a general shortcode theme enable ?

推荐答案

要执行单个短代码,请使用

To execute a single shortcode, run it with

echo do_shortcode('[your_short_code]');

如果短代码在帖子内容中,请确保使用

If the shortcode(s) are in the post content, make sure you're displaying it with

<?php the_content();?>

<?php echo apply_filters('the_content',$post_content);?>

<?php echo apply_filters('the_content',$wp_query->post->post_content);?>

重要的是:如果你不使用函数the_content()",你需要这一行 <?php echo apply_filters('the_content',$wp_query->post->post_content);?> 在第二个参数中,您必须放置要显示的帖子内容的变量.

The important thing is: if you aren't using the function "the_content()" you need this line <?php echo apply_filters('the_content',$wp_query->post->post_content);?> where in the second argument you have to put the variable of the post content you want to show.

这篇关于在 wordpress 主题中启用短代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆