Title: [insert_php] won&#039;t execute when used inside Store Locator Plus plugin
Last modified: August 22, 2016

---

# [insert_php] won't execute when used inside Store Locator Plus plugin

 *  Resolved [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/)
 * I’m trying to modify the results of a list of stores, and am editing the template
   provided by Charleston in their Store Locator Plus plugin. In fact, everything’s
   working except for one small thing…urlencode() a URL in the template. I’m passing
   some custom stuff through there, but the links are breaking because part of the
   concatenated URL are not encoded.
 * Here’s an example of what I’m trying to achieve:
 * `<span class="slp_result_contact slp_result_website"><a href="/leaving?company
   =[insert_php]return urlencode('do_shortcode([slp_location name])');[/insert_php]&
   url=[slp_location url wrap website]">[slp_option label_website ifset url]</a>
   </span>`
 * Been trying to figure out a solution to this for days, and so far no luck. Hopefully
   there’s a way to run something in functions.php to get the [insert_php] to actually
   execute. Unfortunately, it doesn’t appear to be. This is what the link looks 
   like when I inspect it in Chrome Inspector:
 * [http://my.site.com/leaving?company=%5Binsert_php%5Dreturn%20urlencode(%27do_shortcode(Some-Company%20&%20Associates)%27)](http://my.site.com/leaving?company=%5Binsert_php%5Dreturn%20urlencode(%27do_shortcode(Some-Company%20&%20Associates)%27));[/
   insert_php]&url=http://www.somecompany.com/
 * …although, ideally I’d hope for…
 * [http://my.site.com/leaving?company=Some-Company+&+Associates&url=http://www.somecompany.com/](http://my.site.com/leaving?company=Some-Company+&+Associates&url=http://www.somecompany.com/)
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/page/2/?output_format=md)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341407)
 * return should be used only within a function. Try echo, instead. Or neither, 
   just `urlencode('do_shortcode([slp_location name])');`
 * It’s also possible the function do_shortcode() is unavailable to Insert PHP. 
   Insert PHP works by putting the code between the tags through eval() and anything
   that’s not local in scope won’t function.
 * More info about Insert PHP idiosyncrasies is here:
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php)
 * Will
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341409)
 * Interesting. I tried echo first…with no luck.
 * Let me try with your example.
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341410)
 * That didn’t work.
 * Here’s the oddity that I was trying to say in my first post, though. [insert_php]
   isn’t even being executed in their area that I put your shortcode. I’m confident
   that if I can get your shortcode function to work, that this will work as intended…
   but I don’t know what to do in order to get [insert_php] to actually execute 
   as PHP.
 * Right now, the shortcode itself (yours) is getting output to the URL, which means
   it’s not being parsed. As for what needs to be done in order to force it to be
   parsed…not sure.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341411)
 * Check the server error log. It may contain a clue.
 * Will
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341412)
 * Another thing to consider is that Store Locator Plus may be doing something with
   the PHP codes.
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341413)
 * Thanks. I will check that.
 * Unfortunately, what I’m seeing…is about the equivalent to what I would see when
   a shortcode text outputs to a post or page. Generally that means that a shortcode
   isn’t being evaluated at all in said content area.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341414)
 * Perhaps Store Locator preempts the shortcode on the page.
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341415)
 * Also, your shortcode work in the page their solution is embedded onto. Just not
   within the content areas they give me to place content. So I know your plugin
   works (I’ve used it before). Just not sure how to get the shortcode to be read
   and evaluated in this “other area” of WordPress.
 * Checked the logs…nothing there. 🙁
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341416)
 * > Perhaps Store Locator preempts the shortcode on the page.
 * The funny thing is, their own shortcodes do work in that same content area.
 * `[slp_location name]`
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341417)
 * Something to try. Use Insert PHP somewhere above the current section to store
   the URL to a global variable. Then use the global variable for the URL. Don’t
   know whether or not it would work, but a different way to approach it.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341419)
 * Also, see what happens when you remove the do_shortcode() function and feed [
   slp_location name] to urlencode() straight.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341420)
 * I gotta run in a moment, just one more thing I thought of.
 * Perhaps Insert PHP is trying to run before Store Locator has replaced the [slp_location
   name] shortcode.
 * Sorry I can’t stand by. I’ll check back in the morning (Chicago time).
 * Will
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341424)
 * Tried a few things. I put this at the top of the content area they give me:
 * `[insert_php]echo 'test';[/insert_php]`
 * And this is what outputs to the browser when I do:
 * `[insert_php]echo 'test';[/insert_php]`
 * It’s basically not even being read in as a shortcode. Totally weird.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341480)
 * Let’s make sure Insert PHP plugin is activated.
 * If yes, I’m thinking Store Locator is preventing the plugin from doing its job.
 * Will
 *  Thread Starter [ashworth](https://wordpress.org/support/users/ashworth/)
 * (@ashworth)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/#post-5341490)
 * Yep. Your plugin is certainly activated, as I can use it elsewhere in the WP 
   site.
 * Just wasn’t sure how to “force” compatibility to let it work in their field, 
   necessarily (or anyone else’s plugin for that matter). Would be a good trick 
   to know if it’s something that can be re-used in various other plugins doing 
   the same thing.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/page/2/?output_format=md)

The topic ‘[insert_php] won't execute when used inside Store Locator Plus plugin’
is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 17 replies
 * 2 participants
 * Last reply from: [ashworth](https://wordpress.org/support/users/ashworth/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/insert_php-wont-execute-when-used-inside-store-locator-plus-plugin/page/2/#post-5341552)
 * Status: resolved