douhanzhen8927 2011-02-21 20:37
浏览 60
已采纳

使用Wordpress“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.

  • 写回答

1条回答 默认 最新

  • dsce23640 2011-02-21 20:44
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探