Geoserv
Member
Posted 2 years ago #
Using version 2.8.5
I am trying to display my recent blog posts on a non-Wordpress page.
I tried using:
<?php
require(‘./wp-blog-header.php’); // alter to path to wp-blog-header.php script on your site
?>
<!– if you want to have a title graphic it goes here –>
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
# <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a> <small> in <?php the_category(’, ‘) ?> </small><small><?php the_time(’m-d-Y’); ?> <?php the_time(’g:i a’); ?></small><br />
<?php endforeach; else: ?>
<!– put what you want here when there are no posts –>
<?php endif; ?>
but it doesn't display anything.
Is there something else that will work?
Thanks.
Geoserv
Member
Posted 2 years ago #
I tried that method and received the following error:
Fatal error: Call to undefined method stdClass::set_prefix() in /path/to/my/wp-settings.php on line 268
Not sure why it would be showing wp-settings.php though.
Any ideas?
vanderlow
Member
Posted 2 years ago #
The example in the Codex assumes that you are embedding wordpress directly into your page template.
A lot of people need to integrate such wordpress functionality into a CMS or using a PHP framework. This usually means that the example code is added inside a function. The error only occurs when trying to include wordpress from inside a function (something needs to have global scope?).
I've been looking around for a solution, but haven't found one anywhere. I did find this related big report though - it's been assigned to 3.0:
https://core.trac.wordpress.org/ticket/11066