• Resolved nickk40

    (@nickk40)


    I’m trying to migrate from another plugin to Code Snippets. I have a PHP snippet that works if I select Auto insert in combination with Run Frontend Only.

    However, I would like to use the Shortcode option instead of Auto insert. So I select Shortcode, which gives me [wpcode id="4334"], which I insert as a shortcode (at the top) on one of my pages. But then the code snippet no longer works (it doesn’t seem to be executed anymore). I have set the priority of the code snippet to 1 and use no conditional logic.

    Any idea what might be the problem?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter nickk40

    (@nickk40)

    Might the problem perhaps have something to do with that the script uses wp_head and that this perhaps is not possible in combination with a Shortcode…? Because hello does get printed on the page I include the snippet shortcode.

    echo("hello");
    add_action( 'wp_head', function () {
    	?><style>.foo {display:none!important;}</style><?php
    	...
    • This reply was modified 2 years, 3 months ago by nickk40.
    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @nickk40,

    The shortcode provided by Code Snippets is [code_snippet id="4334"] not [wpcode]. It sounds like you might have the wrong plugin installed for this support forum.

    Thread Starter nickk40

    (@nickk40)

    Ah, you’re absolutely right. My apologies.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Shortcode for php snippet not working’ is closed to new replies.