这是我通过传入帖子ID来获得我想要的结果,即帖子标题:
// Get Post Title outside of loop
// USE: [get-post-details post="123"]
function title_by_id($atts) {
$atts = shortcode_atts( array(
\'post\' => 0,
), $atts, \'title-from-id\' );
$id = $atts[\'post\'];
$data = get_the_title($id);
return $data;
}
add_shortcode( \'title-from-id\', \'title_by_id\' );