WordPress.org

Support

Support » Plugins and Hacks » runPHP plugin; calling function repeatedly — can I do this?

runPHP plugin; calling function repeatedly — can I do this?

  • Sorry, I wish I was better versed in php; I’d probably know the answer already.

    But before I moved to a wordpress platform, I took my pages and added php datafeed pulls like this:

    (top of the page:)
    <?
    $query = “widgetX or widgetB and not (widgetC)”;
    include_once (‘/home/server/www/shopping/search-new.php’);
    ?>

    Then I’d have a bunch of html, and then I’d call a function within the script I just included, usually several times on the page:

    BLAH BLAH BLAH BLAH
    <? dosearch(‘cachename’,$query,’0′,’8′); ?>

    BLAH BLAH BLAH BLAH BLAH
    BLAH BLAH BLAH BLAH more html BLAH

    BLAH BLAH

    <? dosearch(‘cachename’,$query,’8′,’8′); ?>
    BLAH BLAH BLAH BLAH BLAH

    Is there any way I can replicate this within wordpress/runPHP without “including” the entire script over and over again? I can’t seem to pass a value, much less a function, from one <? php ?> block to another.

    I hope I explained this okay; if not, let me know and I’ll try to clarify. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, anyone? I’d really appreciate any thoughts. I know someone with more knowledge must have tried this before.

    If running WordPress 2.0, I may have recommended placing dosearch() and any related functions in a file called functions.php, and drop that into your active theme’s directory. WordPress includes it automatically, however it’s loaded after plugins, so it’s possible RunPHP will still not see it.

    Have you thought of including search-new.php in the runPHP plugin file?

    No, I haven’t thought of doing that. 🙂 But I will *definitely* try it. It didn’t occur to me to try to load my personal script in a more global way. I appreciate the suggestions and I’ll post back on how it went. Great thoughts; thanks so much!

    If we’re talking Pages here, I find it so much easier to just do a custom Page template.

    http://codex.wordpress.org/Pages#Page_Templates

    (The codex is having a few issues at the moment though.)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘runPHP plugin; calling function repeatedly — can I do this?’ is closed to new replies.
Skip to toolbar