WordPress.org

Ready to get started?Download WordPress

Forums

Showing the whole last post on homepage (8 posts)

  1. T3RCZ
    Member
    Posted 1 year ago #

    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

  2. vtxyzzy
    Member
    Posted 1 year ago #

    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' );
    ?>
  3. T3RCZ
    Member
    Posted 1 year ago #

    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?

  4. vtxyzzy
    Member
    Posted 1 year ago #

    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

  5. T3RCZ
    Member
    Posted 1 year ago #

    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. :(

  6. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  7. T3RCZ
    Member
    Posted 1 year ago #

    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();
  8. vtxyzzy
    Member
    Posted 1 year ago #

    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;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic