Wordpress First Post Full Rest Excerpt

suply
suply used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.

Author

Commented:
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

Author

Commented:
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.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Yes, we just need to move the "if" statement around a little bit to incorporate some more of the code.


This should get rid of the read more link for the first post, as for the image I am not sure. It looks like it is using some custom functionality that was built into your theme "Lioit".

 <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-->
<?php
if($postCount > 1){
?>
                            <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-->
<?php } ?> 
                        </div><!--End article-->
                        <?php endwhile; ?>
						<?php  else:  ?>
                        <?php  endif; ?>
                        <?php lio_pagination(); ?>
                         </div>

Open in new window

Author

Commented:
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
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

Author

Commented:
Thanks!

Author

Commented:
jrm213jrm213

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial