Wordpress do_shortcode()和post_内容
我想从帖子内容中获得任何帖子的标题。因此,我在functions.php中做了以下工作Wordpress do_shortcode()和post_内容,wordpress,Wordpress,我想从帖子内容中获得任何帖子的标题。因此,我在functions.php中做了以下工作 function my_title($title) { global $post; // Do whatever here with your title... $content = $post->post_content; print $content; $title =$content. $post->p
function my_title($title)
{
global $post;
// Do whatever here with your title...
$content = $post->post_content;
print $content;
$title =$content. $post->post_title . ' | ' .
get_bloginfo('name');
return $title;
}
它在帖子内容中打印短代码,但如果我应用$content=do\u短代码($content)代码>它不会生成实际的帖子内容。当我应用$content=do\u shortcode($content)代码>网站挂起。让我知道如何使用$content=do\u shortcode($content)此函数中的代码>以便可以更改标题 你能试试这个吗。我想是你的html o/p导致了这个问题
$content = $post->post_content;
$content = wp_filter_nohtml_kses( $content ); // this wp_filter_nohtml_kses indicates strip_tags
$content = do_shortcode( $content );
或
这里的$var
是什么?这里的do\u shortcode
有什么用?你能解释一下你想要实现什么吗?@SudharshanNair我编辑这篇文章是个错误$var输入错误。当它调用$content=do_shortcode($content)时,我遇到了问题;当我打印$content时,它会显示页面上存在的短代码,但如果这是作为do_shortcode()中的参数传递的,我会得到错误。@NARAYANCHANGDER。通过将WP\u DEBUG
设置为trueyes,您至少可以跟踪错误并找出问题的真正原因。我在第573行的C:\xampp\htdocs\WP\WP content\plugins\mtouch quick\mtouchquick.PHP中发现了错误“PHP致命错误:ob\u start():无法在输出缓冲显示处理程序中使用输出缓冲”。你知道如何修复它吗?嗨,我已经得到了修改SEO标题的代码,你能检查一下为什么我无法在该功能中提取帖子内容吗?这将是一个很大的帮助。过去几个月我一直在寻找解决方案,但运气不好。@NARAYANCHANGDER请为此发布新问题
echo do_shortcode(get_post_field('post_content', $post->id));