INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Thumbnail for excerpts plugin showing entire post

Thumbnail for excerpts plugin showing entire post

(OP)
I've installed the thumbnail for excerpts plugin, but when a post has an image, the entire post (not just the excerpt) appears on the main page. Posts without any images show just the excerpt as expected. Ideas on how to change this?

I've the latest install of both wordpress and the plugin working with MAMP.

Thanks,
Donna
 

RE: Thumbnail for excerpts plugin showing entire post

i assume that all works fine with the plugin disabled?

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Yes - just excerpts appear - and my test post that doesn't have an image associated just shows the excerpt with the plugin enabled. I did not modify anything - just simple enabling.

Donna

RE: Thumbnail for excerpts plugin showing entire post

Could you post your template code please.

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Sure - this is from the main page file. I haven't gone far at all, as you can see.

CODE

<?php get_header(); ?>



 <!-- posts  -->
<div id="posts" class="span-16 prepend-1 append-1">
    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    
        <div class="post" id="post-<?php the_ID(); ?>">
            <div class="postheader">
                
                <div class="posttitle">
                    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
                    
                </div>
            </div>
            <div class="postcontent"><?php the_excerpt(__('<br/>Continue reading...')); ?></div>
            <div class="posttags"><?php the_tags('Tags: ', ', ', ''); ?></div>
        </div>
        
    <?php endwhile; ?>
    
    <div class="navlinks">
        <?php next_posts_link('&laquo; Previous posts') ?> <?php previous_posts_link('Next posts &raquo;') ?><br/><br/>
        <a href="#posts"><img src="<?php bloginfo('template_directory'); ?>/images/backtotopicon.gif" alt="Back to top" />Back to top</a>
    </div>
    
    <?php else : ?>
    
    <div class="post">
        <h2>Not found!</h2>
        <p><?php _e('Sorry, this page does not exist.'); ?></p>
        <?php include (TEMPLATEPATH . "/searchform.php"); ?>    
    </div>
        
<?php endif; ?>
</div>
    
<?php get_sidebar(); ?>

<?php get_footer(); ?>

Thanks,
Donna

RE: Thumbnail for excerpts plugin showing entire post

that all looks fine save that the_excerpt() does not take any arguments.  try removing the argument and seeing what happens.

CODE

<div class="postcontent"><?php the_excerpt(); ?></div>
also the_excerpt() is simply an output function for get_the_excerpt() BUT it has its own filter.  make sure that you do not have any plugins enabled that might hook onto the_excerpt() or, alternatively, change this line of the plugin code

CODE

add_filter("get_the_excerpt", "putThumbnailForExcerpts");
to

CODE

add_filter("the_excerpt", "putThumbnailForExcerpts");

the plugin itself looks fine (although a bit heavy handed).

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Thanks - I'll take a look at it. I'd tried changing the reading settings in the dashboard to just display the summary, but had to change the_content to the_excerpt for it to work that way. Then the thumbnails got it really screwed up. I'll try your changes. I don't know enough about the plugins yet to have found something different to display thumbnails with the posts.

I'll check back when I've put this in.

Thanks,
Donna

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Well, I made those changes, but nothing changed. So it's like it flops stuff if there is no thumbnail to use. When I change the page code to

CODE

<div class="postcontent"><?php the_excerpt(); ?></div>
the posts WITHOUT images associated show up fine (just the summary), but the posts with images show all the text.

When I change the page template to

CODE

<div class="postcontent"><?php the_content(); ?></div>
the post with images works as intended, but all text (not just summary) shows for the test post without an image.

Suggestions or another way to go on this? I'm in the very early stage of this since I'm a first-timer and am quite flexible.

Thanks,
Donna

RE: Thumbnail for excerpts plugin showing entire post

i'm not fully following you donna.

you say that if you use the_content(), you don't get any images.  in this scenario, the plugin does not get fired at all.  so the problem must relate to something else.

the summary setting in the admin panel is for rss/atom feeds, not for display on a web page.

can you post a link to your blog so that i can see what is going on? and can you confirm how the images are being uploaded?

RE: Thumbnail for excerpts plugin showing entire post

here is an alternative piece of code. it does not do any image resampling and is intended just to help debug your issue.

CODE

<?php
/**
Plugin Name: Debug Excerpts and Thumbnails
Author URI: rathercurious.net
Plugin URI:
Description: quick and dirty thumbnail addition for excerpts.  no image resampling done.
Author: Justin Adie
Version: 0.0.1
*/

add_filter("the_excerpt", "debugExcerptThumbnails");

function debugExcerptThumbnails($excerpt){
    if(is_single()) return $excerpt;
    global $post;
    $pattern = '/<img.*? src\s?=\s?([\'"])(.*?)\1.*?>/i';
    preg_match($pattern, $post->post_content, $match);
 //print_r($post);
    if (empty($match[2])) {
        return $excerpt;
    }
    $img = '<img width="150" src="'.$match[2].'" align="left" />';
    
    return $img.$excerpt;
}
?>

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Sorry for the confusion - with the get_content the thumbnail plugin works as intended, but I get all text for posts that don't have images associated. I may try to find a generic image for any posts that don't have a specific photo to see if that will help. I'll also look at the debug in a little while. I'm home sick today anyway.

Thanks,
donna

RE: Thumbnail for excerpts plugin showing entire post

using get_content(), the plugin will never 'work'.  it will never be called and will never do anything.

my plugin works fine on all the posts i've checked.  you (obviously) need to use the_excerpt() rather than the_content() to retrieve the excerpts.  if there is no image then the plugin will return just the excerpt text.

likewise, i'm at home sick. been bedridden with fevers etc since new year's eve.  everything is taking twice as long!

 

RE: Thumbnail for excerpts plugin showing entire post

(OP)
Got it. Edited the post and works now - never know why. Using the_excerpt. Now just to figure out modifying themes and I'll be good for this part.

Geez - sorry you're sick so long - it does make everything slow down. I've never slept so much!

Thanks again,
Donna

RE: Thumbnail for excerpts plugin showing entire post

Please someone help me. I have installed the plug-in but can't seem to get it to work.  I have played with the code for hours to no avail.  The below is my original code.  If someone would tell me what needs to be changed I would be most grateful.  

</div>
<?php endif; ?>
<div class="PostContent"><?php if (is_search())the_excerpt(); else the_content(__('More... &raquo;', 'kubrick')); ?></div>

  

Thanks

Andrew
 

RE: Thumbnail for excerpts plugin showing entire post

@amiles42

please start a separate thread for your issue.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close