How can I access the $atts in a BuddyPress template?
function test_shortcode_callback( $atts, $content='' ) {
ob_start();
shortcode_atts(
array(
'foo' => 'this is foo',
'bar' => 'default bar',
), $atts, 'test_shortcode' );
bp_get_template_part('my-template');
return ob_get_clean();
}
add_shortcode( 'test_shortcode', 'test_shortcode_callback' );
Unlike load_template
, bp_get_template_part
does not have an $args
parameter.
In the template, has_shortcode( $post->post_content, 'test_shortcode' );
returns true .
But how can the $atts be accessed? I could store them in post meta, but I hope there is a simpler approach.