更新时间:2023-11-30 23:20:10
我使用3个技巧将WordPress内容输入CodeIgniter:
get_file *
这类似于使用XMLHttpRequests,但是类似于服务器端。请注意,您也可以IFrame页面,但iframe似乎有点麻烦给予#1和#2。
I use codeigniter and need to display last 3 posts at footer from blog as blabla.com/blog located.
when I create a test.php file as below. it works well,
test.php
<?php
// Include Wordpress
define('WP_USE_THEMES', false);
require('./blog/wp-blog-header.php');
query_posts('showposts=3');
?>
<ul>
<?php while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
but when I copy same code to footer_view.php of codeigniter structre, it doesnt work and giving error as below:
error at codeigniter footer_view:
Fatal error: Call to undefined method stdClass::set_prefix() in /blabla/blog/wp-settings.php on line 268
any idea what can be the problem? :/ appreciate helps!!
I've used 3 tricks for getting WordPress content into CodeIgniter:
get_file*
. This is similar to using XMLHttpRequests, but server side.Note, you could also IFrame the page, but IFrames seem a bit hackish given #1 and #2.