简体   繁体   中英

Using Wordpress “Template Tags Outside of Wordpress”

Hey I'm doing some php development work for free for my friend and he is using wordpress for a blog, but it's a video site & while I could do something clever within wordpress itself, I want to move outside of wordpress since it isn't my specialty but I would like to be able to retrieve Wordpress information and while it would be quite plausible for me to simply create php to retrieve data from the database wordpress has a lot of template tags already in existance. What I would like to be able to do is utilise these tags in my project.

So my question is, how can this be achieved?

In case it is important. Wordpress is installed in the document root and it's currently sharing that root with my external site. so in other words the index.php of wordpress is in the same folder as the "index.php" of my other one, though obviously not called the same thing.

You could "load" WP functions, with this 3 lines

$file = dirname(__FILE__);
$file = substr($file, 0, stripos($file, "wp-content") );

require( $file . "/wp-load.php");

After that you can use any WP function, or custom function or anything you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM