• Resolved pashlikson

    (@pashlikson)


    Hello.

    Currently I am working on website which is using WordPress 6.2 and a Raft theme. I hired programmer to make custom currency calculator for this project and we noticed that shortcodes aren’t working at all. I tried switching to default WordPress themes ‘twenty twenty-three’ or ‘twenty twenty-one’ and got same result.
    Also I added test_shortcodes function to functions.php file, which should output ‘Shortcodes are working!’ when you call it on pages. Instead i got only [test_shortcodes] text on the page, which indicates that shortcodes indeed aren’t working.
    Please help diagnose and solve this issue.

    Thanks in advance, Paul

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Please show the full code you wrote for your test shortcode.

    Thread Starter pashlikson

    (@pashlikson)

    function test_shortcodes()
    {
    return ‘Shortcodes are working!’;
    }
    add_shortcode(‘test_shortcodes’, ‘test_shortcodes’);

    Works fine for me with twenty twenty-one. Do you have any plugins active? Deactivate them for a test.

    Thread Starter pashlikson

    (@pashlikson)

    Just tried deactivating everything and issue still persists.
    Also I saw people talking about relative issue suggesting to use content display:
    echo apply_filters(‘the_content’,$post->post_content);
    instead of standart:
    echo $post->post_content;
    But I am not really familiar with php so I am not sure if this can help me

    • This reply was modified 1 year, 10 months ago by pashlikson.

    If you use a default theme like twenty twenty-one this will already be taken care of for you. You don’t have to do anything. The shortcode must therefore also work.

    Thread Starter pashlikson

    (@pashlikson)

    Yes, I know. But it isn’t working.
    Maybe shortcode feature needs some special permissions on server or php modules?
    We’re using DigitalOcean droplet for website hosting.

    No, there are no server requirements for this.

    But have a look at Tools > Site Health to see if there are any anomalies mentioned. This could be independent of your problem.

    Thread Starter pashlikson

    (@pashlikson)

    Just checked – everything looks fine, it only suggesting to update plugins and telling that background updates not working as expected.
    For me it seems like there’s problem with droplet setup and thus WordPress is limited in functional. I’m trying different hosting to check if problem still persists

    Thread Starter pashlikson

    (@pashlikson)

    I think I figured it out.
    For anyone running into the same problem: until around 2021, most WordPress themes ran on php template files (header.php, single-page.php, footer.php, etc.). Later, themes were implemented entirely on Gutenberg blocks, the so-called FSE – Full Site Editing. Therefore, such themes work on ordinary HTML templates, in which the main WordPress functions are not connected, such as wp_head and wp_footer, which are required for the shortcodes. For example, the standard theme Twenty Twenty-One still works on old php templates, while the more recent Twenty Twenty-Two and Twenty Twenty-Three are based on the FSE principle. So is the Raft theme I used on my project. I still don’t know how to make shortcodes work on FSE themes, but I was able to rebuild the entire website on the Twenty Twenty-One theme using Elementor. So, after spending a few days, I got working shortcodes and a website that looks the same as before.
    I think this topic can be closed.

    UPD: Probably i misspell Twenty Twenty-Two theme when was creating topic. Because, as I said, shortcodes ARE working on Twenty Twenty-One theme, but later on – don’t.

    Shortcodes also work in FSE themes, of course. Would be bad if not. Here is an example how to insert your shortcode in TwentyTwentyThree via shortcode block:
    https://imgur.com/a/7Sbp209

    And this is how it looks in the frontend: https://imgur.com/a/MDljWQk

    The only challenge is that you have to use the code

    function test_shortcodes()
    {
     return 'Shortcodes are working!'
    }
    add_shortcode('test_shortcodes', 'test_shortcodes');

    can’t put it into a functions.php because a FSE theme doesn’t have something like that. I put it in a separate plugin. But you can also use the plugin Code Snippets.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Shortcodes not working’ is closed to new replies.