如果帖子标题是“概念”,我希望帖子内容是这样的“在”帖子标题“中,我们通过遵循”帖子标题“高质量策略来关心我们的客户满意度,所以我希望帖子内容包括”概念“,并将其替换为帖子标题我认为wordpress短代码api可以做这样的事情。但我不知道该怎么做?
发布于 2013-12-05 04:14:34
我不完全理解你的陈述。但我认为wordpress钩子可以帮助你做到这一点,你可以尝试一些类似的方法:
function change_post_title ( $post_title ) {
if ( $post_title == 'conecpts' ) {
$title = 'The new title';
return $title;
}
return $post_title;
}
add_filter('the_title', 'change_post_title');如果标题是“概念”,则会将帖子标题更改为“新帖子标题”。
请将您的问题弄清楚,说明问题是什么,以及您想要实现什么。
发布于 2013-12-05 05:13:57
在你的帖子内容中,你需要在你想要打印标题的地方添加一个短码,在下面的短码示例中,你将使用[post_title]。
function post_title_shortcode( $atts ){
extract( shortcode_atts( array(
'post_id' => get_the_ID()
), $atts ) );
return get_the_title( $post_id );
}
add_shortcode( 'post_title', 'post_title_shortcode' );有了这个短码,你可以传递帖子id,这样如果你想获得另一个帖子的标题,你可以使用短码[bartag post_id="123"],其中123是你想要显示的标题的帖子id。
https://stackoverflow.com/questions/20384363
复制相似问题