Support » Everything else WordPress » Want current blog excerpt on homepage

  • I am building a site that has static pages, including a homepage and a blog (not on the homepage). I would like to place the latest blog post on the homepage (with all the other information I have there). I have seen something called the_excerpt() from the WordPress cheat sheet. Can it be used for this? Does anyone know how to use it? The whole site is in WordPress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I have seen something called the_excerpt() from the WordPress cheat sheet. Can it be used for this?

    Not by itself.

    Does anyone know how to use it?

    Yes 🙂

    You’ll need to look at creating a custom query and creating a second Loop in your theme’s index.php file.

    I am looking to do the exact same thing, however the page I need the content to appear on is not within the wordpress blog. Do you believe that is possible as well?

    Could be difficult/clunky if the content isn’t available as a php include file that doesn’t incorporate a header and footer.

    Found a solution that works:
    On your page that’s outside of the wp folder add:


    <?php
    define('WP_USE_THEMES', false);
    require('./blog/wp-load.php');
    query_posts('showposts=1');
    ?>

    in the top of the page, replacing ‘blog’ with whatever folder your blog is in.
    Then add:


    <?php while (have_posts()): the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_excerpt(); ?>
    <p>">Read more...</p>
    <?php endwhile; ?>

    in your page where you want the post to appear. Edit as you see fit.
    Hope this helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Want current blog excerpt on homepage’ is closed to new replies.