Home » Featured, Technology

How to access admin functions outside of the Wordpress Install

11 September 2009 15 views No Comment
Tags: ,

Recently, I needed to call the wp_create_category function call from outside the wordpress install in a source php file. I was advised to use wp-load.php as my include, but that didn’t do the trick as the function I was looking for was sourced in the admin directory.

The solution to this is source the admin.php file located inside the wp-admin directory.

Then you can call the admin functions directly in your php scripts.

include(’../wp-admin/admin.php’);
wp_create_category(’test category.php’);
//that’s it!

Of course, remove the source php file that calls this function so that no one else can call the functions you referenced!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.