WordPress.org

Forums

use a plugin function outside WordPress (5 posts)

  1. rwl
    Member
    Posted 10 years ago #

    I snagged the Hollo Dolly plugin and modified it very slightly to make a random tagline function to use on my blog -- worked great -- and I'm just wondering if it's possible for me to use that new function on files outside my WordPress directory to show the rotating taglines out there too... I tried calling the function with simple php require, like:

    <?php require("../blog/wp-content/plugins/randomtagline.php"); ?>

    ...but outside the WordPress directory, the wptexturize function contained within Hello Dolly (and thus my adapted function) throws a call-to-undefined error. That makes perfect sense to me, but I have no idea if a workaround for this is even possible, let alone how I'd begin to do it. Any sugestions?

  2. Joshua Sigar
    Member
    Posted 10 years ago #

    copy the wptexturize function and put it on that same file.

  3. moshu
    Member
    Posted 10 years ago #

    At the top of the page before anything else (hopefully it's a .php file) you should have this:
    <?php
    require('./path-to-your-blog/wp-blog-header.php');
    ?>

    and after that you can use any WP template tag or WP feature on that page. The above code makes any file "WP aware".

  4. rwl
    Member
    Posted 10 years ago #

    Gotta love the simple solution staring me right in the face! Thanks alphaoide, that was the quickest reply I've ever had to anything. ^^

  5. rwl
    Member
    Posted 10 years ago #

    As good as alphaoide's suggestion was, moshu's has topped it... thanks a ton, moshu, that is exactly what I was looking for and I hope to make good use of it

Topic Closed

This topic has been closed to new replies.

About this Topic