请提供如何集成的代码。我在public_html文件夹中保留了博客,博客有一个数据库,并且网站有我创建的其他数据库。我需要在主页的codeigniter站点显示最近的两个wordpress帖子。
我尝试了这些代码在我的网站index.php
<?php require('blog/wp-blog-header.php');?>
<?php
$args = array('numberposts' => 2, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts($args);
foreach ($postslist as $post) : setup_postdata($post); ?>
<div class="events">
<p><strong><?php the_date(); ?></strong></p>
<p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
</div>
<?php endforeach; ?>
但显示像
Fatal error: Call to undefined function wp_get_recent_posts() in
/home/sharelok/public_html/application/views/index.php on line 124
您需要包括'WP-负荷.php'文件,如果您在wp之外执行任何wp操作。 – Rikesh