• Resolved Masud Chy

    (@masudferoz)


    I want to show the latest one post full content and rest shows excerpt I implement the code

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $counter++; // add +1 to count for each post
    ?>
    <div class="date"> <?php the_date(); ?></div><!--date-->
    <div class="posttitle">
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    </div><!--posttitle-->
    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    	the_post_thumbnail();
    }
    ?>
    <?php
    if  ($counter===1){
    the_content();
    } else {
    the_excerpt();
    }
    ?>

    but it show the full content for all the pages like page 1 page 2 etc then other in excerpt. But I want to show only the first page first latest article in full content. I do not have idea is it possible or not?
    Here is the site https://stacy.breeziecastell.com/ https://stacy.breeziecastell.com/page/2/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Just try this code

    <?php
    $counter = 0;
    if ( have_posts() ) { while ( have_posts() ) { the_post(); $counter++; ?>
    	<div class="date">
    		<?php the_date(); ?>
    	</div><!--date-->
        <div class="posttitle">
        	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        </div>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
    <?php if ($counter == 1){ the_content(); } else { the_excerpt(); }
    }
    }?>
    Thread Starter Masud Chy

    (@masudferoz)

    Hello Rajan V thanks for your quick reply. I replaced the code in index.php after that the page show nothing/blank.

    Thread Starter Masud Chy

    (@masudferoz)

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $counter++; ?>
    <div class="date"> <?php the_date(); ?></div>
    <div class="posttitle"><h2><a>"><?php the_title(); ?></a></h2></div>
    <?php
    if ( has_post_thumbnail() ) { 	the_post_thumbnail();
    }
    ?>
    <?php
    if (is_home() && $counter==1){
    the_content();
    } else {
    the_excerpt();
    }
    ?>

    I changed the condition but no hope any idea please?

    Thread Starter Masud Chy

    (@masudferoz)

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $counter++; ?>
    <div class="date"> <?php the_date(); ?></div><!--date-->
    <div class="posttitle">
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <?php
    if ( has_post_thumbnail() ) { the_post_thumbnail();
    }
    ?>
    <?php
    if( is_home() && !is_paged() && ($posts[0] == $post) ) {
    echo apply_filters('the_content', $post->post_content);
    } else {
    the_excerpt();
    }
    ?>

    Hi it’s working fine now with the above code.

    Thanks masudferoz for this code. Have looked all over for this exact function. Works wonderfully!

    Thread Starter Masud Chy

    (@masudferoz)

    You are most welcome twelve31

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Latest one post full content and rest of the blog pages posts excerpt’ is closed to new replies.