ENV: WordPress version 5.1 / MAMP Pro php v. 7.2.14

I'm building a new, custom theme for a site that has an old, custom theme. The new site is just a single theme, while the old site has a parent theme and a chid theme.

When I change the active theme to my new one, the shortcode that lives in the content area of a Page only renders the text of the shortcode.

When I activate the old child theme it renders perfectly.

Is there something I'm not doing in my new custom theme that is not enabling these shortcodes?

When I enable debugging, I can't get past the if() statement to get to line 196 of shortcodes.php

if ( empty( $tagnames ) ) {
    return $content;

// line 196 --v
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); 

It's like my shortcode isn't gettting registered properly.

shortcode code in functions.php

function first_shortcode() {
    $content = '<h1>This is my first shortcode</h1>';
    return $content;
add_shortcode('my_shortcode', 'first_shortcode');


Adding template code snippets:


 *Template Name: Page

global $pageType;
$pageType = "tier"; // this is used as a body tag class


get_template_part( 'template-parts/navigation');

<main id="main" class="main-container">
        while ( have_posts() ) :

            get_template_part( 'template-parts/content', 'page' );

        endwhile; // End of the loop.




 * Template part for displaying page content in page.php
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 * @package hdms

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <div class="container fat-margin">
        <div class="entry-content">
            <?php echo do_shortcode("[my_shortcode]"); ?>
            <p><strong>the above lives in php calling:</strong></p>
                &lt;?php echo do_shortcode("[my_shortcode]"); ?&gt;

        </div><!-- .entry-content -->
    </div><!-- .container -->
</article><!-- #post-<?php the_ID(); ?> -->

Admin (editing) Page Content:

enter image description here

Rendered using my new theme

enter image description here

Rendered using old theme:

enter image description here

  • Could you look at my answer below? Could you explain to me what you're trying to do/achieve? Also, explain to me the variable $tagnames Commented May 29, 2019 at 20:28
  • what is the code of page.php in your custom theme?
    – Michael
    Commented May 30, 2019 at 0:57
  • I made two WP themes and numerous child themes. And a couple of WP plugins. You say that you can't get past the if() statement, that means your doing something wrong there. Explain to us what you're trying to do and show us all your code or the relevant part. This: $tagnames Commented May 30, 2019 at 5:17
  • page.php & an include are here: gist.github.com/sroberson/30cefbf59b1b10b5667d2bca293dcff6
    – Scott
    Commented Jun 3, 2019 at 18:15

1 Answer 1


I would recommend using single quotes if you want to include some HTML, also you need to return something otherwise nothing happens.

// WP Shortcode
function text_shortcode() {
    return '<strong>bold text:</strong> <a href="https://wordpress.stackexchange.com/questions/318934/shortcode-returns-escaped-html-tags">See wordpress.stackexchange.com</a>';
add_shortcode('bold-text', 'text_shortcode');

Your WordPress shortcode would be:


See my other answers with examples:
- Shortcode created to check language not works
- Shortcode returns escaped HTML tags

  • The addShortcode() function in my functions.php fie does have single quotes.
    – Scott
    Commented May 29, 2019 at 20:26
  • @Scott It doesn't matter, you could use both single and double quotes! Commented Sep 28, 2019 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.