• Hey all,

    I’m working on a client website and I’ve got an idea I need some help with.

    What I’d like to do is present the title and brief snippet of the most recent blog post on the homepage. The homepage will be part of the WordPress install, but it is so heavily customized that this snippet is really the only content being pulled from the WordPress database.

    Here’s a screenshot to give you some context. The section titled “From our blog” is the section I’m referring to.

    Any suggestions on the best way to go about doing this?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • See the codex article on WP_Query.. I would suggest doing a simple get_posts call to retrieve the title and excerpt from the latest post.

    $posts = get_posts( array( 'posts_per_page' => 1) );
    
         foreach ( $posts as $post ) {
             echo apply_filters( 'the_title', $post->post_title; );
             echo apply_filters( 'the_excerpt', get_the_excerpt() );
         }
    Thread Starter Peter G.

    (@peter-g-2)

    Will this need to be inside the loop?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Blog snippets’ is closed to new replies.