我从头开始为wordpress 3.3.1开发一个新主题,并且短代码没有在它上面工作.在我搜索到现在为止,过滤包含短代码的内容,在主题特定位置添加过滤器代码(shorcodes正在使用另一个主题).所以,我的问题是:一般短代码主题启用的代码是什么?
小智 32
要执行单个短代码,请运行它
echo do_shortcode('[your_short_code]');
Run Code Online (Sandbox Code Playgroud)
如果短代码在帖子内容中,请确保您正在显示它
<?php the_content();?>
Run Code Online (Sandbox Code Playgroud)
要么
<?php echo apply_filters('the_content',$post_content);?>
Run Code Online (Sandbox Code Playgroud)
要么
<?php echo apply_filters('the_content',$wp_query->post->post_content);?>
Run Code Online (Sandbox Code Playgroud)
重要的是:如果你没有使用函数"the_content()",你需要这一行<?php echo apply_filters('the_content',$wp_query->post->post_content);?>,在第二个参数中你必须放置你想要显示的帖子内容的变量.
| 归档时间: |
|
| 查看次数: |
28375 次 |
| 最近记录: |