Support » Fixing WordPress » Showing the whole last post on homepage

  • T3RCZ

    (@t3rcz)


    Hi everyone,

    I’ve been looking for a solution to this problem for a few last hours. All I need is to show the latest post instead of the list of the recent post. I need to show it as normal single post page, including navigation and everything. I failed with all the solutions I found here & on the interwebz.
    The only one that at least partly works is this part of code embedded into home.php:

    <?php
    $i=0; // Initialize to Zero;
    if (have_posts()) :
    while (have_posts()) : the_post();
    if ($i==0) {$recentpostid = $post->ID; $i=$i+1;}
    endwhile;
    endif;
    //get only the latest post
    $posts = query_posts( ‘p=’.$recentpostid.”‘”);
    ?>

    When I enter the page, the article appears in full length – that’s alright. But the navigation (previous + next) leads to another articles, just as if I was viewing one older article.
    Can anyone please help me? I’m only partly experienced in PHP.
    Sorry for asking this question again, but I just didnt manage to find a working solution for this problem. Thank you everyone.

    My webpage:
    http://blog.matejhejda.net

Viewing 7 replies - 1 through 7 (of 7 total)
  • vtxyzzy

    (@vtxyzzy)

    Partly a guess, but I think you can replace all the code above with this:

    <?php
    global $query_string;
    query_posts( $query_string . '&posts_per_page=1' );
    ?>
    T3RCZ

    (@t3rcz)

    Thanks for the reply!
    It actually shows the last post, but only the excerpt with “Continue Reading” (You can see it on my page.). I’d like it to show the whole post. Any other idea how to do it?

    vtxyzzy

    (@vtxyzzy)

    More than likely, it needs to be controlled a bit further down in your code. Try setting the $more variable as shown here, except that you want to assign a value of -1: http://codex.wordpress.org/Customizing_the_Read_More#How_to_use_Read_More_in_Pages

    T3RCZ

    (@t3rcz)

    First of all, I’d like to apologize, my experience with php is very, very basic.

    I edited the code as following:

    <?php
    global $query_string; $more = -1;
    query_posts( $query_string . '&posts_per_page=1' );
    ?>

    But nothing happened. Woudln’t you mind to show me how to use this? Im sorry to bother you, I’m just not sure how this works. 🙁

    vtxyzzy

    (@vtxyzzy)

    The $more code needs to go a bit further down in your code than you have shown. Please post about 10 lines of the code starting with what you showed above.

    T3RCZ

    (@t3rcz)

    I use the Platform theme, so it’s a bit complicated. I tried to copy the existing single.php file when creating the home.php, but it consists only of this:

    <?php
    /*
    	This theme is Copyright (C) 2008-2010 Andrew Powers, PageLines.com (andrew AT pagelines DOT com)
    */
    
    setup_pagelines_template();

    So I put the code mentioned above ABOVE this part of code.

    My complete home.php looks like this:

    <?php
    global $query_string; $more = -1;
    query_posts( $query_string . '&posts_per_page=1' );
    the_content( $more_link_text , $strip_teaser );
    ?>
    <?php
    /*
    	This theme is Copyright (C) 2008-2010 Andrew Powers, PageLines.com (andrew AT pagelines DOT com)
    */
    
    setup_pagelines_template();
    vtxyzzy

    (@vtxyzzy)

    Try replacing this:

    <?php
    global $query_string; $more = -1;
    query_posts( $query_string . '&posts_per_page=1' );
    the_content( $more_link_text , $strip_teaser );
    ?>

    with this:

    <?php
    global $query_string;
    query_posts( $query_string . '&posts_per_page=1' );
    if (have_posts()) : while (have_posts()): the_post();
    global $more; $more = -1;
    the_content( $more_link_text , $strip_teaser );
    endwhile; endif;
    ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Showing the whole last post on homepage’ is closed to new replies.