WordPress.org

Ready to get started?Download WordPress

Forums

Run PHP Functions in Pages and Posts? (9 posts)

  1. jdcfsu
    Member
    Posted 8 years ago #

    I am looking for a plugin that allows this. I have found a few hacks for WP1.2 and prior, but so far nothing I have tried works with WP2.0. Anyone know of any or a way of doing this?

  2. MichaelH
    Member
    Posted 8 years ago #

    Check this page for compatibility with 2.0:
    2.0 plugin compatibility

    I know these worked in 1.5.2
    PHPExec Plugin
    http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/

    RunPHP Plugin
    http://www.nosq.com/2004/10/runphp-wordpress-plugin/

  3. spencerp
    Member
    Posted 8 years ago #

    Use the second one MichaelH posted, it's much better! =) That's coming from experience lol! =)

    spencerp

  4. gmdavis62
    Member
    Posted 8 years ago #

    Both of these plugins (runPHP and PHPexec) will add <br /> after each line of the includes. I only know this because when I use php include to add a javascript file, all these <br />s get added and ruin the code.

    When I include a PHP file, it just doesn't work but doesn't show up in the html code-view.

    As I asked elsewhere, is there a setting for WP I can turn off?

  5. spencerp
    Member
    Posted 8 years ago #

    gmdavis62, so you tried adding javascript to a "page" then, while using one of them plugins? If so, why are you doing that? Those plugins are for using "php" within a page, not javascripts.. :/

    spencerp

  6. circuitor
    Member
    Posted 8 years ago #

    This was supposed to be a feature of WP 2.0. (previously 1.6).
    See Here:
    http://codex.wordpress.org/Version_1.6#Pages

    Any one know what happened to it? I would be a nice feature to have :)

  7. gmdavis62
    Member
    Posted 8 years ago #

    To claify: I was using javascript (embedded in a PHP file) as an include. PHP can include any type of file in a webpage. These plugins SHOULD be able to support this or wordpress should allow you to turn off the automatic adding of <br /> after each line.

  8. gmdavis62
    Member
    Posted 8 years ago #

    UDATE: I just found that (for both runPHP and PHPexec) if you enclose your php in <pre> <pre> tags, WordPress won't insert <br /> at the end of each line of the resulting html.

    However, some php includes still don't work as expected. I'm not sure yet what is happening.

  9. davidchait
    Member
    Posted 8 years ago #

    If you are looking to call singular functions, or include one specific file, CG-QuickPHP is a faster method in many cases. It can make one function call with static-typed parameters (though it accepts strings, numbers, and true/false), so it can do an include("file") just as easily as any other function. Just FYI.

    -d

Topic Closed

This topic has been closed to new replies.

About this Topic