Title: Escaping $ When Calling do_shortcode
Last modified: August 31, 2016

---

# Escaping $ When Calling do_shortcode

 *  Resolved [00coday](https://wordpress.org/support/users/00coday/)
 * (@00coday)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/escaping-when-calling-do_shortcode/)
 * I am using wp-rss-aggregator to display RSS feeds from several sites. In a normal
   page the plugin behaves as expected. However, when calling echo do_shortcode(“[
   wp-rss-aggregator source=$feed_id]”) inside [insert_php] tags, any text starting
   with $ (like dollar amounts) are cut off to the first delimiter. An example would
   be $2,000 would be display as ,000.
 * Do I need to run call it with an str_replace in there somewhere to escape the
   $ characters or something?
 * Thanks in advance for the help.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

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

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/escaping-when-calling-do_shortcode/#post-6987818)
 * Because the content between the [insert_php] and [/insert_php] tags is processed
   by the PHP eval() function, $ characters need to be escaped. Otherwise, the characters
   following $ are assumed to be a variable.
 * There are a couple other characters that need special handling. See
    [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements)
 * Will
 *  Thread Starter [00coday](https://wordpress.org/support/users/00coday/)
 * (@00coday)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/escaping-when-calling-do_shortcode/#post-6987882)
 * Thanks Will. I replaced:
    do_shortcode(“[wp-rss-aggregator source=$feed_id]”)
   with str_replace(‘$’, ‘\$’, do_shortcode(“[wp-rss-aggregator source=$feed_id]”))
   and everything looks better.
 * Thanks for the help.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/escaping-when-calling-do_shortcode/#post-6987884)
 * You’re welcome, 00coday. And I’m happy you found a solution.
 * Will

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

The topic ‘Escaping $ When Calling do_shortcode’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/escaping-when-calling-do_shortcode/#post-6987884)
 * Status: resolved