• Resolved Ramona

    (@nextend_ramona)


    I downloaded WordPress 5.9-RC1 to try the new full site editor using the “WordPress Beta Tester” plugin, and while I was testing it, I noticed that the shortcode block does not transform the shortcodes in the page template. (Works fine in the actual page/post content.)

    I created a new plugin and I added the following testing code to it:

    add_shortcode('note', 'tt_test_note');
    function tt_test_note($atts, $content = null) {
        ob_start();
        ?>
        <div class="note" style="margin: 30px 0; padding: 27px 40px; background: #fcf3dc; border-radius: 5px;">
            <p><?php echo $content; ?></p>
        </div>
        <?php
        return ob_get_clean();
    }

    <h2>Environment:</h2>
    1. WordPress 5.9-RC1
    2. Active theme: Twenty Twenty-Two Version: 1.0
    3. Active plugins: only the shortcode plugin that has the code above and nothing else
    4. PHP: 7.2.34-28+ubuntu18.04.1+deb.sury.org+1

    <h2>What’s the issue?</h2>
    When using the shortcode [note]test[/note] in Gutenberg’s own shortcode module works in the actual page, but not in the template editor.

    <h2>How to reproduce the problem?</h2>

    1. Create a new plugin and add the code mentioned above
    2. Go to Appearance > Editor
    3. Click on the WordPress icon at the left site
    4. Select Templates > Page
    5. Add a new shortcode block above Post title (https://imgur.com/5lFPgtE)
    6. Write this code there: [note]test[/note]
    7. Save the template
    8. Create a new page
    9. Add a new shortcode block and write the same shortcode there (https://imgur.com/5lFPgtE)
    10. Save the page and check it

    You’ll see the [note]test[/note] code is displayed above the post title, but the yellow block shows correctly up below.

    View post on imgur.com

    <h5>Note</h5>
    The same shortcode works if I place it into the “Header” or “Footer” part.

    View post on imgur.com

    View post on imgur.com

    Playing around with it more, it seems the shortcode starts working after I create a template part from the whole section. Still weird that it does not work by default.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    I’ve just tested your shortcode and on

    • WP 5.9-RC1-52464
    • TT2 1.0 pulled from GH repo

    And all seems OK: https://i.imgur.com/0Y19xRb.png

    Thread Starter Ramona

    (@nextend_ramona)

    Hi @sebastienserre

    Thanks for looking into this! Did you place the shortcode into the new editor, or just the post’s content? The post content works fine. The issue is when the new editor is used (Appearance > Editor (beta)).

    I’ve just updated to 5.9-RC1-52464, and I can still reproduce the issue.
    New “beta” editor: https://imgur.com/o4bPPa6
    Page content: https://imgur.com/9j3gusE
    Frontend: https://imgur.com/576sFam

    The shortcode added to the page content displays fine. Shortcode added to the new “beta” editor’s “header” section works fine. Shortcode added to the new “beta” editor’s main content area doesn’t work.

    Did you use this new editor at Appearance > Editor (beta)? If not, can you reproduce the error there?

    You’re right I reprooduce. You should open a Trac ticket to report this to the developers.
    Don’t hesitate to link this thread to help developers to understand how to reproduce.

    Thread Starter Ramona

    (@nextend_ramona)

    Thanks for confirming!

    What would be the best to open a Trac ticket? I found the place to report a bug:
    https://core.trac.www.ads-software.com/newticket
    but I don’t seem to be able to select 5.9 there.

    Select “trunk” (it means the version currently built)

    Thread Starter Ramona

    (@nextend_ramona)

    Ooh, thank you! I’ll open the Trac ticket shortly.

    Done: https://core.trac.www.ads-software.com/ticket/54759

    • This reply was modified 2 years, 10 months ago by Ramona.
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    We mark posts that have trac tickets as resolved for sanity. It lets mods and volunteers know we don’t have to jump in and find an issue. You should follow the discussion on trac. You can click the ‘Watch’ button on the trac ticket (it’s near the bottom) to get email alerts. If you need to log in, it’s the same ID/password as you use for the forums.

    Thread Starter Ramona

    (@nextend_ramona)

    I’m sorry, I didn’t know that. Thanks for the information and marking the topic as solved. I’ll keep that in mind next time!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcodes are not working in page templates’ is closed to new replies.