I try to show on my homepage only the last post, in complete version.

I tried numerous methods unsuccessfully.

I tried in particular to create a specific template: “front-page.php”, in which I put this code:

        global $post;
        $args = array( 'posts_per_page' => 1 );
        $lastposts = get_posts( $args );
        foreach ( $lastposts as $post ) :
          setup_postdata( $post ); ?>
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <?php the_content(); ?>
        <?php endforeach;
        wp_reset_postdata(); ?>

But only title and a link “more” appears.

I also tried in the settings to put for the homepage the "last posts" and the number of post to 1, it works, but the problem is that my pages of archive shows no more than one post.

Yet, I would like the last whole post on the homepage, and the titles of 10 last ones posts in the pages of archive.

Do you know what to do?


Just before the line of the_content(), add this:

$more = "";

This will set the 'more' flag to false, so the entire post should be displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.