Forums

[resolved] PHP in a text widget (15 posts)

  1. Nyana
    Member
    Posted 3 years ago #

    I've checked some of the RunPHP tags here to find a sollution, but can't find the answer to the following problem:

    I'm using Sidebar Widgets plugin to make adding stuff to my sidebar a piece of cake. Now I am trying to add code in a text widget, but even with RunPHP and Exec-PHP I can't seem to run something terribly easy as <?php include("somescript.php"); ?>

    Any work-arounds to fix this?

    Cheers!

  2. Nitallica
    Member
    Posted 3 years ago #

    I've had no problem including scripts in my posts and pages using both Exec-PHP and RunPHP. Have you tried putting in the full path to the script? That's what I had to do to mine.

  3. Nyana
    Member
    Posted 3 years ago #

    I tried using the full path, but no result. I'm not sure if a Textbox Widget counts as a post/page.

    Is there something like <RunPHP></RunPHP> to execude the script?

  4. Nitallica
    Member
    Posted 3 years ago #

    Hrm, now that I think about it, a textbox widget I don't guess would be covered by the RunPHP/Exec plugins because technically I guess that's not a page/post.

    I'm not entirely clear on how the widgets work, so I'm afraid I'm of little further help to you. :(

    Perhaps someone more knowledgeable could step in?

  5. samsarin
    Member
    Posted 3 years ago #

    The text widget it not designed to allow you to use PHP code. I have written a custom plugin to allow me to use PHP in widgets. It may need to be polished a bit, but I can post it seomwhere if it is of interest.

  6. Nyana
    Member
    Posted 3 years ago #

    Thanks for the feedback both :)

    @samsarin: If your widget works I wouldn't mind testing it out for you.

  7. samsarin
    Member
    Posted 3 years ago #

    I have published the Samsarin PHP Widget. I hope you find it useful and would appreciate any suggestions you have about how to make it more useful.

  8. Nyana
    Member
    Posted 3 years ago #

    Samsarin, your widget works excellent! It now executes the php script properly. Thanks for the widget you made!

    Problem solved now.

  9. samsarin
    Member
    Posted 3 years ago #

    You're most welcome Nyana. I'm glad I could be of help :).

  10. Calmatt
    Member
    Posted 2 years ago #

    Any possibility of reposing that widget, I'm having the same problem :'(

  11. agidi
    Member
    Posted 2 years ago #

    Would it be safe to deploy on a WPMU site?

    please do repost it :)

  12. RandomWhim
    Member
    Posted 2 years ago #

    Thanks much! Great widget.

  13. Otto42
    Moderator
    Posted 2 years ago #

    The ExecPHP widget does the same thing and is somewhat simpler to use.

  14. theblade24
    Member
    Posted 2 years ago #

    Otto, I am using your php widget in MU. What is happening is the code I insert in the widget is being remove when I save it.

    The widget goes blank.

    Is this an MU issue? Is there a version of your plugin to work in MU?

  15. gagnews
    Member
    Posted 2 years ago #

    Sorry if this has been touched upon but how can I get php code into my created pages? ie: under Manage, Pages, Create new page.

    In this new page I would like to reference my Recent Posts utilizing the existing code from my index.php file.

    Basically I want to create a "homepage" that isnt the default wordpress page but I'd like it to function the same way and reference certain posts. When I paste the code into the page via wordpress backend it doesn't work on preview, when I re-open it to edit the page the code is all messed up.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags