将wordpress博客链接到CodeIgniter视图 [英] Linking wordpress blog to CodeIgniter View

查看:57
本文介绍了将wordpress博客链接到CodeIgniter视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这是交易.我有一个名为codeigniter的框架的网站.这是PHP中的MVC框架.我正在尝试使用wordpress API,以便在CodeIgnite中设置一个使用wordpress API来获取博客帖子的视图.

Well, here's the deal. I have this site with a framework called codeigniter. It's a MVC framework in PHP. I'm trying to use the wordpress API in order to set up a view in CodeIgnite that uses the wordpress API to get blog posts.

,因此博客位于/wp-blog/中,而codeigniter框架位于/system/中.因此,在codeigniter视图中,我调用require_once('/wp-blog/wp-load.php');,wp-load文件将打开一个配置文件,其中包含数据库信息.但是,当我从我的角度调用它时,它不起作用.但是,当从/wp-blog/index.php调用它时,向我显示数据库没有问题

so the blog is in /wp-blog/, and the codeigniter framework is set up in /system/. so in the codeigniter view, I call require_once('/wp-blog/wp-load.php'); the wp-load file opens a config file with the database info on it. However, when i call it from my view, it doesn't work. However, when it's called from /wp-blog/index.php, it has no problem showing me the database

我不知道这是否是权限问题.我显然能够访问配置文件,因为我收到一条错误消息,提示'username'@'localhost'并且用户名正确.

I don't know if it's a permissions issue. I'm clearly able to access the config file, because I get an error message that says 'username'@'localhost' and the username is right.

因此,如果他们都获取相同的文件,并且都使用mysql_connect()函数执行相同的文件,为什么一个人只能在博客内部工作,而一个人却无法工作?

so if they are both getting the same file, and both executing the same file with the mysql_connect() function, why would one only work from inside the blog, and one does not work?

这是错误:

A PHP Error was encountered

Severity: Warning

Message: mysql_connect() [function.mysql-connect]: Access denied for user 'theuser'@'localhost' (using password: YES)

Filename: wp-includes/wp-db.php

推荐答案

您的方法是错误的.您的CodeIgniter控制器需要运行一个 curl 请求,博客的XML-RPC API端点并处理响应,然后根据需要显示它.

Your approach is wrong. Your CodeIgniter controller needs to run a curl request to the blog's XML-RPC API endpoint and process the response, then display it as you need to.

第二种选择是仅在页面上使用iFrame,尽管iFrame在2005年的某个时候被取缔.

A second option is to just use an iFrame on the page, although iFrames were outlawed at some point in 2005.

这篇关于将wordpress博客链接到CodeIgniter视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆