When you look at how do_shortcode()
actually works, then it’s this:
do_shortcode( $content )
Where $content
is defined as the following:
(string)
Content to search for shortcodes
What you are trying to do is to echo
what the shortcode does, leading to a false assumption. There is no magic function discovering your shortcode. The shortcode simply is a callback (a function or a method) attached to some string that you can put between square brackets in full text content. When the content is read during the livecycle/runtime and is found, then the attached callback is executed in its place. Pretty much the same as what happens with actions and filters. So
add_shortcode( 'bartag', 'bartag_func' );
allows this
[bartag foo="bar"]
where bartag_func
is the callback. For e.g.:
function bartag_func( $atts )
{
$args = shortcode_atts( array(
'foo' => 'no foo',
'baz' => 'default baz',
), $atts );
return "foo = {$args['foo']}";
}
What you are (or should be) searching for is where the shortcode gets added with add_shortcode()
. Then just find the callback (for e.g. the bartag_func()
) and execute or echo it
echo bartag_func();
That’s it.