I've switched on Gutenberg and am trying to create a shortcode on a page. This is my code in functions.php
// Enable shortcodes in text areas
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
// Enable shortcodes
add_filter( 'the_excerpt', 'shortcode_unautop');
add_filter( 'the_excerpt', 'do_shortcode');
function first_shortcode() {
$content = '<h1>This is my first shortcode</h1>';
return $content;
}
add_action('my_shortcode','first_shortcode');
In the post, I've put [my_shortcode] in the shortcode section, as follows:
But when I display the page, it just renders [my_shortcode]. I'm running Wordpress 4.9.8
Thank you