Support » Fixing WordPress » PHP in Sidebar?

  • rideforver

    (@rideforver)


    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,phpEXEC, 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

    (@boober)

    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/

    Thread Starter rideforver

    (@rideforver)

    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

    (@boober)

    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

    (@rideforver)

    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

    (@jonimueller)

    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

    (@kalessin)

    How are you trying to insert your php statements into the sidebar?

    Thread Starter rideforver

    (@rideforver)

    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

    (@whistler2020)

    have you tried using <?php echo $display1; ?>

    Thread Starter rideforver

    (@rideforver)

    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..

    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

    (@rideforver)

    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

    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.