Title: PHP in Sidebar?
Last modified: August 19, 2016

---

# PHP in Sidebar?

 *  [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/)
 * Ok so I’m trying to insert php code into my sidebar, not the post and none of
   the php plugins seem to allow this. AT the moment WP is stripping the php tags
   out (which I understand is a protection measure), but does anyone know a plugin
   that will allow php code in the sidebar.
 * So far, Ezstatic crashes on line 129 or so, [runPHP](http://www.nosq.com/blog/2006/01/runphp-plugin-for-wordpress/),
   [phpEXEC](http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/),
   don’t work and nor does the excellent PHP-Exec plugin which I often use. All 
   work in the post area but not in the sidebar where I need them to.
 * Any Suggestions?
    Thanks, Steve

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

 *  [boober](https://wordpress.org/support/users/boober/)
 * (@boober)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718496)
 * those are all only for executing php in posts. you need a widget one.
    this one
   says it executes php in text widgets as well [http://wordpress.org/extend/plugins/exec-php/](http://wordpress.org/extend/plugins/exec-php/)
 *  Thread Starter [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718499)
 * Yeah, I’ve seen that one, but it would mean widgetising the entire sitebar including
   some hefty if statements and wpg2 image blocks that I’m not sure can be done.
   I’m looking for an easier solution first as I think there must be a way of displaying
   a simple echo statement in an existing sidebar.
 *  [boober](https://wordpress.org/support/users/boober/)
 * (@boober)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718500)
 * wait, so youre trying to add php directly in the sidebar.php file? there shouldnt
   be a problem then. what exactly are you trying to execute there?
 *  Thread Starter [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718503)
 * The program is a php based picture of the day script, displayed on a html page
   by echoing a function of the script (<?php echo($display1); ?>). On all my .html
   pages, I’m able to parse php code in the html using .htaccess but in my WordPress
   sidebar the system strips out the php tags leaving an empty div – which is why
   i was trying the php plugin option. What do you think?
 *  [jonimueller](https://wordpress.org/support/users/jonimueller/)
 * (@jonimueller)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718743)
 * It should be fine and dandy. I am running a php date calculator right in the 
   sidebar and it’s fine.
 * Is there something in your .htaccess file causing this maybe?
 * WP doesn’t strip out PHP in the sidebar.
 *  [Kalessin](https://wordpress.org/support/users/kalessin/)
 * (@kalessin)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718749)
 * How are you trying to insert your php statements into the sidebar?
 *  Thread Starter [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718777)
 * In the <head> section is an include call to the php picture of the day script
   which seems to work…
 * <?php include (“displayer/displayer.php”); ?>
 * …then the call in the sidebar is an echo of a function of the above script
 * <?php echo($display1); ?>
 * The latter function isn’t showing up in the html code when viewed through my 
   browser, which caused me to think it had been stripped out! I’ll look at it more
   and post back though.
 *  [whistler2020](https://wordpress.org/support/users/whistler2020/)
 * (@whistler2020)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718779)
 * have you tried using `<?php echo $display1; ?>`
 *  Thread Starter [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718780)
 * Yes I did! The problem is not wordpress but in second and third level directories
   where the function to display the picture isn’t functioning.
 * The script I’m using is online [here in this pastebin.](http://www.pastebin.ca/960588).
 * If I place an include call to the script using an absolute URL in the header 
   it outputs the author’s credit line, but for some reason the function call to
   the image directory made in the page body fails to work on html pages in second
   and third tier directories.
 * I’ve tried placing absolute URLs in the displayer script (as you’ll see in the
   pastebin above), but then the script fails to find the images full stop.
 * I’m scratching my head over this one. The script is great with hotlinking and
   periodic rotation but doesn’t work in directories.
 *  Thread Starter [rideforver](https://wordpress.org/support/users/rideforver/)
 * (@rideforver)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718781)
 * It’s an issue with the urls, that I can’t figure out. The script is simple and
   offers great customisation but I’m using the following script now instead which
   works across the site with no more headaches:
 * [http://webscripts.softpedia.com/script/Ad-Management/Hercules-Image-Rotator-41598.html](http://webscripts.softpedia.com/script/Ad-Management/Hercules-Image-Rotator-41598.html)
 *  [geekjon](https://wordpress.org/support/users/geekjon/)
 * (@geekjon)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718835)
 * I’ve noticed the same problem. I had some simple PHP in my sidebar, and no matter
   what I try I cannot get it to work. I’ve tried placing the PHP in text widgets,
   in “PHP Code” widgets, and straight in the sidebar.php file. No matter where 
   the PHP is in the sidebar, it is stripped out.

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

The topic ‘PHP in Sidebar?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 6 participants
 * Last reply from: [geekjon](https://wordpress.org/support/users/geekjon/)
 * Last activity: [18 years, 2 months ago](https://wordpress.org/support/topic/php-in-sidebar/#post-718835)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
