Support » Fixing WordPress » Embed only the latest post

  • Resolved sketchee


    I want to embed just the latest post from my wp blog ( 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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • 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:

    Not 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

    Worked great: Thanks

    Thanks, keep this around, Very helpful.



    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.



    Could this just not work in 2.0.4?

    When I try this I get


    Can’t select database

    We were able to connect to the database server (which means your username and password is okay) but not able to select the christia_wrdp1 database.

    Any ideas? The blog works just fine.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Embed only the latest post’ is closed to new replies.