Avatar of suply
suply asked on

Wordpress First Post Full Rest Excerpt

Hello, I want to have only latest post show un full and rest in excerpt. I have attached the code of the file that shows posts in home page.

I've tried to apply codes from the web without success.

Note: currently it is showing all posts in equal format. I only need the first one in full and the rest just an extract.

Thanks in advanced.
code.txt
PHPWordPressBlogs

Avatar of undefined
Last Comment
suply

8/22/2022 - Mon
jrm213jrm213

Try replacing that code with something like this
 <div class="singlePost">
                    <?php 
$postCount = 0;
if(have_posts()) : while(have_posts()) : the_post('');
$postCount++;
?>
                   
                    	<div class="article">
                        	<div class="articleDetails">
                            	<div class="articleTitle">
                                     <a href="<?php the_permalink();?>"><h1><?php the_title(); ?></h1></a>
                                </div><!--End articleTitle-->
                                <div class="articleMeta">
                                   <ul>
                                        <li class="postAuthor"><?php the_author(); ?></li>
                                        <li class="postDate"><?php the_time('d M Y'); ?></li>
                                        <li class="postCat"><?php the_category(', ') ?></li>
                                        <li class="postComments"><?php comments_popup_link(__('<span class="icon"></span> 0 Comments', 'lioit'), __('<span class="icon"></span> 1 Comment', 'lioit'), __('<span class="icon"></span> % Comments', 'lioit')); ?></li>
                                       
                                    </ul><!--End Post Meta-->
                                    
                                </div><!--End articleMeta-->
                            </div><!--End Article Details-->
                            <div class="articleContent">
                            	<div class="articlePostThumb">
                                     <?php $img = catch_that_image($post->ID); ?>
                                    <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
                                    <img src="<?php echo Lioit_URI; ?>/scripts/timthumb.php?src=<?php echo $img ?>&amp;w=200&amp;h=150&amp;zc=1" alt="<?php the_title(); ?>" />
                                    </a>
                                </div><!--End LatestPostThumb-->
                            	<p><?php 
if($postCount > 1){
                  the_excerpt_max_charlength(''); 
                  echo(" ...");
}
else
{
    the_content();
}

?></p>
                            </div><!--End ArticleContent-->
                            <div class="articleBtm">
                            	<?php require Lioit_TM . '/share.php';?>
                                <div class="articleReadMore">
                                	<a href="<?php the_permalink();?>"><?php _e('Read More' , 'lioit' ) ?></a>
                                </div><!--End More-->
                            </div><!--End Article Bottom-->
                        </div><!--End article-->
                        <?php endwhile; ?>
						<?php  else:  ?>
                        <?php  endif; ?>
                        <?php lio_pagination(); ?>
                         </div>

Open in new window


so basically outside "The Loop" we set the postCount to 0; Inside the loop for each iteration the postCount variable is incremented and that value is checked before displaying the post excerpt or content. If it is <= 1 then display the full post content, if it is > 1 then display the excerpt content.
ASKER
suply

Hello jrm213jrm213, thanks. I used it and it's almost perfect. Please see the attached image. As you can see, there are two images. I'd need only the big one.

Also, is it possible to remove the read more button only for the lastest post?

Regards.
JC.
img.PNG
ASKER
suply

I managed to delete the thumb image left side. Latest full post is OK but I'd like to have other post to show their big image

Is this possible?

Thanks.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
jrm213jrm213

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
suply

jrm213jrm213, we're almost done thanks once again. Read more is gone, latest post big image is showing, I managed to remove the thumb, but for the rest of the posts is it possible to have and post image as the one that's currently as latest post?

I'm attaching a screen shot
img.PNG
jrm213jrm213

I am unfamiliar with the function "catch_that_image" that is being called to retrieve the post image. I am guessing it comes from a plugin or is built into your custom theme.

Nothing in the code is excluding the "non-first" posts from having an image displayed so it must be something in that function. Could you post the code that you are currently using that you modified to not display the thumbnail?

If you have a featured image set for the page you can use the function the_post_thumbnail to display it

http://codex.wordpress.org/Function_Reference/the_post_thumbnail
ASKER
suply

Thanks!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
suply

jrm213jrm213

Is it possible that when you click page 2 the first post doesn't show full?