Reputation: 23
I made a basic shordcode
function map_test(){
$map_render = '<p>test</p>';
return $map_render;
}
add_shortcode( 'map_shortcode', 'map_test' );
and the shortcode is created and all works fine until i do
if ( shortcode_exists( 'map_shortcode' ) ) {
echo do_shortcode('[map_shortcode]');
}
i get the
Test
rendered but after the element there is also a number 1 with double quotesSo i was wondering why is that "1" there and what made it render, also how to remove it?
Upvotes: 1
Views: 53
Reputation: 23
So the solution was to remove the 'echo' from echo do_shortcode, and the "1" is removed, ty all for your time.
if ( shortcode_exists( 'map_shortcode' ) ) {
do_shortcode('[map_shortcode]');
}
Upvotes: 1
Reputation: 347
Try the following to check short code existence and remove the same:
function shortcode_exists( $tag ) {
global $shortcode_tags;
return array_key_exists( $tag, $shortcode_tags );
}
Upvotes: 2