带有小html的简单快捷代码$id+$title



我只需要在wordpress上的文章末尾放一个带有帖子id和帖子标题的短代码。我想在$id前面加一个(ref:(,并将其全部包含在h4 中

所需的结果看起来像这个

<h4 ref: 123 this is my first post <h4>

我很难理解如何做到

我的短代码

function post_id_title( ){
$id = get_the_ID();
$title = get_the_title();
$result = $id . $title ;
return $result;
}
add_shortcode( 'page_title', 'post_id_title' );

试试这个吧,因为你已经把最难的部分做好了。

function post_id_title( ){
$id = get_the_ID();
$title = get_the_title();
$result = "<h4>ref: $id $title</h4>";
return $result;
}
add_shortcode( 'page_title', 'post_id_title' );

最新更新