I want to embed just the latest post from my wp blog (sketchee.com/wp) on the bottom of my main page. I couldn’t figure out how I could do this. Is there a way just to generate an include file that I can use a server side incude to put the file into the html (not php) front page?
If you are going to include WordPress content on a page, it must be a PHP page (end with a .php or .phtml). The entire page could be static HTML, just give it a .php or .phtml extension.
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-config.php'); ?>
Check this out:
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) :
<a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
<?php the_content(); ?>
<?php endforeach; ?>
Here’s more information:
wp-config. Use this instead:
<?php require('./path-to-your-blog/wp-blog-header.php'); ?>
I’ll give it a try when I get home this evening. Let you know how it goes! Thanks
This code isnt working for me, am I doing something wrong. Im using the Static Front Page plugin and editing the “HTML” of home.php.
- The topic ‘Embed only the latest post’ is closed to new replies.