将Wordpress Post与Cakephp3集成 [英] Integrate Wordpress Post with Cakephp3

查看:68
本文介绍了将Wordpress Post与Cakephp3集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cakephp 3.x,并希望在我的网站上显示博客部分。我想在网站上使用WordPress功能。

I am working on cakephp 3.x and want to display blogs section on my site. I want to use WordPress feature in my site.

我已经在本地服务器上安装了WordPress 4,然后将WordPress表导入cake的数据库中并放置了WordPress文件夹

I have installed WordPress 4 on my local server, then I have imported tables of WordPress into cake's database and put the WordPress folder into webroot folder of Cakephp.

在应用程序控制器的initialize()函数中,我将该代码如下:

In app controller's initialize() function I have put this code as follows:

    global $wpdb;
    define('WP_USE_THEMES', false);
    require($_SERVER['DOCUMENT_ROOT']."/webroot/blog/wp-config.php");

以便我可以将WordPress嵌入cakephp中(似乎没有帮助)。

So that I can embed WordPress into cakephp (seems this is not helpful).

我已经尝试过本教程,但在此教程链接

I have tried this tutorial but not success on this Tutorial Link.

我知道本教程中的Wordpress文件夹位于webroot文件夹之外,我也尝试过这样做。

I know in this tutorial Wordpress folder is placed out of webroot folder and I have tried that too.

当我使用 http:example.com/blog

它正在询问博客控制器,我了解这是因为 src / controller 文件夹中没有博客控制器。

It is asking for blog controller and I understand this is because of as blog controller is not present in src/controller folder.

我已经尝试过.htaccess代码按照教程中的建议进行,但没有成功。
有人可以帮我解决这个问题吗?请让我知道集成所需的步骤。

I have tried .htaccess code as per suggested in tutorial but no success on that. Can anyone help me out from this problem? Please let me know the required steps for integration.

推荐答案

您可以使用 API

<?php
require('/the/path/to/your/wp-blog-header.php');

$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

来源: http://codex.wordpress.org/Integrating_WordPress_with_Your_Web站点

或尝试WP API;)

Or try WP API ;)

这篇关于将Wordpress Post与Cakephp3集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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