我想在这段php代码的输出中添加一个类
function acf_esg_tax_field_loc( $atts, $content = null ) {
$a = shortcode_atts(array('post_id' => "1"), $atts);
$term = get_field( "field_56cb3d84cf32a", $a['post_id'] );
echo $term->name;
}
add_shortcode( 'acfesgtax_loc', 'acf_esg_tax_field_loc' );
该代码用于我的 Wordpress 函数 php 以生成短代码。
它应该是这样的
function acf_esg_tax_field_loc( $atts, $content = null ) {
$a = shortcode_atts(array('post_id' => "1"), $atts);
$term = get_field( "field_56cb3d84cf32a", $a['post_id'] );
echo '<div class="OutputClass" >';
echo $term->name;
echo '</div>';
}
add_shortcode( 'acfesgtax_loc', 'acf_esg_tax_field_loc' );
不幸的是,这不起作用。
你能帮忙吗?
皈依舞
莫回无