Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to start a funny images website but I have come across a dilemma. I want the website to display 1 post ( not the thumbnail) but the full post on the home page. (the most recent post). Similar to jokideo can anyone please direct me to a theme or provide some code that I need to edit in the wp theme files.

Thanks :)

share|improve this question
1  
You can do this using a page and set that page as a Homepage. Use a custom query for fetching the first post and use a loop to display the post content. –  Rohit Pande Mar 26 '13 at 6:57

4 Answers 4

It depends on what theme you use as they are not coded the same.

Use pre_get_posts or the reading settings and the_content() rather than the_excerpt() in your loop.

function wpsites_home_page_limit( $query ) {
    if ( $query->is_home() && $query->is_main_query() && !is_admin() ) {
        $query->set( 'posts_per_page', '1' );
    }
}
add_action( 'pre_get_posts', 'wpsites_home_page_limit' );

Or you could redirect the latest single post to display on the home page.

share|improve this answer

Create a page template with this code between header and footer:

<?php
/**
 * Template Name: The Last Post
 * 
 */
get_header();

//The code begins here

$the_query = new WP_Query( 'posts_per_page=1' ); 

while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php the_content();
endwhile;

//The code ends here

get_footer(); ?>

Then create a new page, select this template and save it. Now in Settings > Reading, select the option "static page" and define the page created as "Front page".

Also, create a new white page with the blog name —for example— and save it. In Settings > Reading, define this page as "Posts page". Now we have the last post in the front page and all the posts in a blog page.

But we still need to exclude the last post in the loop, in order to avoid duplicate content. You will probably find the loop in the file index.php or loop.php.

Find this line:

if ( have_posts() ) : while ( have_posts() ) : the_post();

And add these lines overriding the last one:

$offset = new WP_Query( 'offset=1' ); 
if ( have_posts() ) : while ($offset -> have_posts() ) : $offset -> the_post();
share|improve this answer
1  
Just a few pointers here, showposts is depreciated, was replaced with posts_per_page. And NEVER use query_posts. Rather use WP_Query, get_posts or use pre_get_posts –  Pieter Goosen Jul 27 at 3:54
    
Good to know that, Pieter. This afternoon when I'm back I will update my answer. Thank you. –  Gerard Jul 27 at 8:45
1  
Updated. I hope it is better now. –  Gerard Jul 27 at 22:46

I would recommend altering the loop that displays the home page posts. Something like

<?php /* Start the Loop */ 
        $i=0; 
        while ( have_posts() ) {

            the_post();

            if($i === 0){
                get_template_part( 'content', get_post_format() );
                break;
            }
            $i++;
        }
?>

There probably are better and more elegant solutions to this, but this is quite simple to implement.

You can edit the file responsible for displaying front page posts (index.php in the twentytwelve theme ), but I wouldn't recommend this seeing that it might be overwritten when updating. It will be better to use a custom theme, maybe a child theme, or to use a custom template file for the front page

share|improve this answer

alter your loop, showposts=> 1, or posts_per_page =>1 numberposts if you're using get_posts(); that should do the trick

share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  Pieter Goosen Jun 16 at 12:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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