【发布时间】:2023-04-06 17:36:01
【问题描述】:
我已经尝试了我能想到的一切。标题在内容包装器的顶部吐出,而 html 标记保留在应有的位置。
我正在从一个页面执行这个简码。我需要媒体库中图像的标题和永久链接,以便我可以吐出 html 以通过短代码在页面上显示它
add_shortcode( 'ispimg', 'isp_gallery_item' );
function isp_gallery_item( $atts ) {
// Attributes
$a = shortcode_atts( array(
'id' => '',
), $atts );
$isp_post_id = get_post($a['id']);
setup_postdata($isp_post_id);
$pt = the_title();
return "<h3>".$pt."</h3>";
wp_reset_postdata();
}
【问题讨论】:
-
首先,您的
wp_reset_postdata();将不起作用。你的错误是什么(不清楚)?以及你想达到什么目标? -
return = "
".$pt."
"; ?? ...和@SamvelAleqsanyan 一样——不清楚你想在这里做什么。
标签: php html wordpress shortcode