Toggle shortcode not working in some categories

I'm not sure if anyone can help with this, but I'm fairly sure it's not a theme issue or the fault of the toggle plugin, but for some reason, the 'toggle' shortcode doesn't work in some categories. I'm using this plugin:
https://wordpress.org/plugins/azurecurve-toggle-showhide/

However, I've tried other toggle plugins and had the same issue.

You can see here that it doesn't work:
https://www.simfansuk.com/wp/sims-2-basic-furniture-recolouring-using-gimp/
but here it does:
https://www.simfansuk.com/wp/ancient-rome-colosseum/ (click the 'Details' tab)

I've tried lots of themes, and it's the same with all of them. I've tried disabling all of the plugins except the toggle one, and it still happens. I'm beginning to think it's a problem with Wordpress itself, but I'm a programming dunce so have no idea how to troubleshoot!

  • James Morris

    Hello angeljs

    I hope you are well today.

    Looking over those pages, there's nothing obvious that sticks out and there are no JS Console messages to give us any clues. But, obviously there's something specific about the categories that are not working that is causing this plugin to not function correctly. In order to dig into this deeper, though, I will need access to your site so I can inspect your categories and see what might be causing this.

    Would you please grant me access to your site?

    You can learn how to grant WPMU DEV Support Access at the following link:

    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5

    Please reply back here once you've enabled access so I will be notified.

    Best regards,

    James Morris

  • Ash

    Hello angeljs

    I was checking this post: https://www.simfansuk.com/wp/sims-2-basic-furniture-recolouring-using-gimp/

    In this post, i can see you used the shortcode like this:

    [toggle]

    But I have changed that to like your other post:

    [toggle title="Click to view credits" border='none']

    But it didn't change anything. Then I have added some words to test as well as removed some words, but it seems it is not taking any effect. Is there anything I should do to change the content of that post? Would you please check and confirm? Just FYI, I was checking this page: https://www.simfansuk.com/wp/wp-admin/post.php?post=32726&action=edit

    Also, can I create a new post on your site to check if the shortcode works?

    Have a nice day!

    Cheers,
    Ash

  • Adam Czajczyk

    Hello angeljs

    I checked your site again and I did two simple test:

    1. I have installed the plugin on my test site (Twenty Seventeen theme and no other plugins active) and literally copied entire content from the post of your site where it is not working.

    2. I have created a new post on your site (under a different name, it's in trash now so it wouldn't be visible on page) and also copied the content from the "non-working" one.

    In both cases... the [toggle] shortcode worked.

    What bothers me, however, is that in that "non-working" post (I focused on the "Sims 2 Basic Furniture...." example from your initial message) it looks like the shortcode isn't even processed. It doesn't seem like e.g. jQuery is failing, thus not hiding the content but instead both opening ([toggle]) and closing ([/toggle]) shortcodes are visible in the content on front-end.

    That usually happens when something's "breaking" shortcode processing. A "weird thing" is that even though I spent great amount of time examining the site, I didn't find any significant differences between posts where this works and posts where it doesn't.

    That being said, I realize that you tried with different themes and with plugins disabled but I'm still thinking about something that's possibly affecting processing the shortcode. Are you sure that there's no e.g. custom code (for example some additional filter on "the_content()" - for example in "functions.php" of the theme? Are there any custom templates used (I can't see that as Editor is disabled under "Appearance" admin menu)?

    Best regards,
    Adam

  • Adam Czajczyk

    Hello angeljs

    Thanks for the response and enabling editor.

    I did some more research on the site, though I must admit that I still wasn't able to solve it. I did, however, found one more thing that seems to be strictly related:

    on the posts that are not working, some characters (special characters such as brackets and some other) seems to be "html-encoded".

    What that means is that in the page source instead of seeing e.g.

    [toggle]

    you see

    [toggle]`

    Another example would be that instead of a phrase

    If you’ve ever wondered

    you got

    If you’ve ever wondered

    Those characters are properly rendered in the browser so you do see [ and ' on front-end and in post editor. But they are not processed by WP and that perfectly explains why the [toggle] shortcode in such post is not actually applied and why it does show literally in the post content.

    Now, the problem is why this happens. There are two possibilites here: either they are encoded upon post saving or they are saved properly but are encoded when displayed but before shortcodes are processed.

    Thanks to Editor being enabled I was able to check theme and I can see there's a lot of custom code (and some I don't quite now what is doing - mostly the parts that are fetching some things from external sources) but I didn't find anything that could be doing this. I might have missed something but so far, I didn't spot it.

    I think we should start further search with finding out whether this encoding happens upon post saving or not and that can be done by looking into the database. I assume that you have some access to it so you could check the "wp_posts" table via phpMyAdmin. What would you want to do would be to find the post of ID 32726 (that's the "Sims 2..." post we're focusing on now) and look at the value of "post_content" in that table.

    Check please, if you can find the

    [toggle]

    shortcode explicitly there or if there's

    [toggle]

    string instead.

    This way, we'll know whether the shortcode is saved as encoded (thus broken) or not (therefore, that is happening after post content is fetched). It won't solve the problem but should at least show the further path to investigate :slight_smile:

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.