[wp-hackers] Embed WP Post in Page outside WP. Tried,
but getting error.
One Eyed View
awarner20 at yahoo.com
Thu Aug 16 20:43:52 GMT 2007
Hi everyone, this is my first post here (just found this list). I have a
question about embedding a WP post in my .php page outside of my WP
installation. I'm trying to include just the latest post on the main page of
my site. Seems relatively easy right?
I found this thread on the WP forums
http://wordpress.org/support/topic/83086. Here what it says...
Any page that is outside the WP installation can still have WP stuff on it.
Just add this to the top of the page:
<?php require('pathtoyourwordpressinstall/wp-blog-header.php'); ?>
So, if you put that little bit of code at the top of the page, this should
work to display the most recent post:
$posts = get_posts('numberposts=1');
foreach($posts as $post) :
"<?php the_permalink(); ? " id="post-<?php the_ID(); ?>"><?php the_title();
<?php the_content(); ?>
<?php endforeach; ?>
So, I tried this and I am getting an error: Fatal error: Call to undefined
function: get_posts() in
/home/content/a/a/a/myusername/html/newsite/index.php on line 78
The file I am including, wp-blog-header.php seems to includes this line:
require_once( dirname(__FILE__) . '/wp-includes/functions.php');
I've looked inside the functions.php page and searched for get_posts(), but
did not see a reference to it.
My main page is here: http://mysite.com/newsite/index.php
My blog is here: http://mysite.com/blog/
I am using the latest version of WP (Version 2.2.2)
Would anyone here be able to clue me in as to what's going wrong here, or
maybe point me in the right direction of where to look? I would be very
View this message in context: http://www.nabble.com/Embed-WP-Post-in-Page-outside-WP.-Tried%2C-but-getting-error.-tf4279389.html#a12180557
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
More information about the wp-hackers