Title: Shortcode for php snippet not working
Last modified: August 7, 2022

---

# Shortcode for php snippet not working

 *  Resolved [nickk40](https://wordpress.org/support/users/nickk40/)
 * (@nickk40)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-php-snippet-not-working/)
 * 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](https://wordpress.org/support/users/nickk40/)
 * (@nickk40)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-php-snippet-not-working/#post-15895201)
 * 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 3 years, 10 months ago by [nickk40](https://wordpress.org/support/users/nickk40/).
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-php-snippet-not-working/#post-15895210)
 * Hi [@nickk40](https://wordpress.org/support/users/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](https://wordpress.org/support/users/nickk40/)
 * (@nickk40)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-php-snippet-not-working/#post-15895267)
 * 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.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [nickk40](https://wordpress.org/support/users/nickk40/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-php-snippet-not-working/#post-15895267)
 * Status: resolved