简体   繁体   English

使用Wordpress“ Wordpress之外的模板标签”

[英]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. 嘿,我正在为我的朋友免费进行一些php开发工作,他正在使用wordpress创建博客,但这是一个视频网站,尽管我可以在wordpress本身中做一些聪明的事情,但我想移出wordpress,因为它不是。这是我的专长,但我希望能够检索Wordpress信息,而对于我来说,仅创建php从数据库检索数据的WordPress似乎已经很合理了。 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. Wordpress已安装在文档根目录中,并且当前正在与我的外部站点共享该根目录。 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. 因此,换句话说,wordpress的index.php与我的另一个index.php位于同一文件夹中,尽管显然没有叫同样的东西。

You could "load" WP functions, with this 3 lines 您可以使用这3行来“加载” WP函数

$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. 之后,您可以使用任何WP函数,自定义函数或任何所需的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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