WordPress.org

Support

Support » Plugins and Hacks » use a plugin function outside WordPress

use a plugin function outside WordPress

  • 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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • copy the wptexturize function and put it on that same file.

    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”.

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

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘use a plugin function outside WordPress’ is closed to new replies.