WordPress.org

Ready to get started?Download WordPress

Forums

runPHP plugin; calling function repeatedly -- can I do this? (5 posts)

  1. blakekr
    Member
    Posted 8 years ago #

    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!

  2. blakekr
    Member
    Posted 8 years ago #

    Hi, anyone? I'd really appreciate any thoughts. I know someone with more knowledge must have tried this before.

  3. Kafkaesqui

    Posted 8 years ago #

    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?

  4. blakekr
    Member
    Posted 8 years ago #

    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!

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.