• Resolved nuriarai

    (@nuriarai)


    Hello, I can’t show you a post because I’m still on local development. The issue is that if I put this piece of code in my single template (single.php), the shortcode is not executed. If I put the shortcode inside the content it runs correctly.
    <?php echo do_shortcode( ‘[toc heading_levels=”2″ start=”3″]’ ); ?>
    But I want to put it in a differennt position that those the plugin offers. Isn’t it possible?

    Thanks in advance!

    • This topic was modified 1 year, 1 month ago by nuriarai.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Prabhat

    (@prabhatrai)

    Hi there,

    Thanks for the details!

    The reason your current approach isn’t working is because the [toc] shortcode doesn’t directly generate the TOC HTML. Instead, it returns a placeholder (<!–TOC–>), which gets replaced with the actual TOC later during WordPress’s the_content filter processing.

    Since this filter doesn’t run when you call the shortcode manually in a template, the TOC never gets generated in that context.

    I’d be happy to test and provide you with a custom solution. Please reach out to us directly at [email protected] so I can assist further.

    I’m really looking forward to helping you.

    frafor

    (@frafor)

    I am having the same issue but still your reply that doesn’t make any sense: what’s the shortcode intended for if it’s not possible to use it outside of the content? I even tried “apply_filters(‘the_content’, do_shortcode(‘[toc]’));” and all I get is a <p></p> tag.

    • This reply was modified 1 year ago by frafor.
    Plugin Support Prabhat

    (@prabhatrai)

    Hi @frafor,

    Currently, we don’t have a shortcode that works when added outside the content area.

    However, as mentioned in my last reply, I’d be happy to test and provide a custom solution. In this case, please reach out to us directly at [email protected] so I can assist further.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding shortcode [toc] by code is not running’ is closed to new replies.