WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How add PHP in sidebar when using widget (6 posts)

  1. meethere
    Member
    Posted 7 years ago #

    Hi i have installed sidebar widget yesterday.

    I have a php code below to show my clients advertisement:


    <li><h2>Sponsors</h2>
    <?php include 'inblogads.php' ?>
    </li>

    Previously when i was not using sidebar widget, i was able to show those ads by putting the above code in sidebar.php of the template.

    But now i am not able to do so. Adding the code in the text box widget also dont work because it can display only text/html contents.

    Also i can add available widget buttons to sidebar but cannot drag back when i dont need them.

    Please please help.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Use my ExecPHP widget, available here: http://ottodestruct.com/wpstuff/execphp.zip

    It's just like a text box widget, but it'll also run PHP code.

    I don't know why you can't drag them back. Try dragging them all the way down to the bottom, until they change shape for the unused widget space below.

  3. relaxedguy
    Member
    Posted 7 years ago #

    That's crazy, what possible reason is there for forcing us to use such a kludge to run PHP in the sidebar?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    relaxedguy: If you don't want to use it or to use widgets, then don't. Nobody's forcing you.

    However, having widgets makes things nicer. No having to deal with PHP to rearrange sidebars. No having to move your hacked sidebar code to a new theme if you change themes (as long as the new theme supports widgets, anyway). Etc, etc...

  5. relaxedguy
    Member
    Posted 7 years ago #

    Perhaps I was not clear. Of course I want to use widgets, who wouldn't? Problem is the widget management system is very crude in terms of functionality. I was rallying against having to run yet another plug-in to enable PHP in widgets, which are built in PHP? The redundancy is weird and unnecessary. I can see blocking PHP in posts and comments, but the sidebar?

  6. meethere
    Member
    Posted 7 years ago #

    The main reason for using phpexec is that I want to add php ads in the sidebar.
    Hope you got it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags