我为wordpress构建了一个非常独特且javascript密集的主题,现在短信不起作用 . 我没有安装任何插件,所以不是这样 . 我从使用短代码所需的wordpress模板文件中删除了什么(即:[gallery]) .
我理解如何制作短代码,但是当WP将其吐出来展示时,WP如何接受你的帖子并替换“[gallery]”?
编辑:这是我目前正在使用的:
$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order", ARRAY_A);
$i = 1;
foreach ($pagepull as $single_page){
echo "<div class=\"section\"><ul><li class=\"sub\" id=\"" . $i . "\"><div class=\"insection\">";
echo $single_page['post_content'];
$i++;
// more code that is irrelevant...
// more code that is irrelevant...
// more code that is irrelevant...
}
5 回答
好的,试试这个
Wordpress会记录您的内容并对其应用过滤器 . 您必须注册过滤器并解析您的内容 .
如果你的主题没有显示你的短代码,可能你输出帖子的内容而不让Wordpress过滤它 .
为帖子调用函数get_the_content()不会为短代码运行过滤器(如果有的话) .
申请
参考:http://codex.wordpress.org/Function_Reference/get_the_content
注意:许多插件使用内容注册过滤器以实现短代码!
如果您想要变量中的内容,请使用此选项:
现在你可以回复$ content;或使用正则表达式或任何你想让内容看起来像你想要的东西 .
我遇到过同样的问题 .
短代码取决于WP Loop,但's a different issue. To make a long story short, I' ve在应该显示短代码的页面上添加了
the_post();
(例如articles.php
) .此外,请确保您使用
the_content()
以显示文本(例如,使用$post->post_data
不会显示短代码) .我的解决方案正在取代
同
正如keatch已经提到的那样,在返回内容之前应用过滤器 .
Read this carefully about the_content
请使用
在功能和使用的开始
在关闭函数之前 .
希望这对你有所帮助 .
干杯