ThemeShaper Forums » Thematic


Post thumbnails for excerpts on home page

(3 posts)
  • Started 10 years ago by jervatron
  • Latest reply from middlesister
  • This topic is not resolved
  1. Hey guys,
    I'm struggling with a post thumbnail issue on my website. . . the thumbnails show up on archive and category pages, but not on the home page.
    I've looked through the forums here, and I'm not well versed enough in PHP to fully understand which php function I need to edit to enable this; so I was hoping for a little guidance.

    Posted 10 years ago #
  2. I now see in the content-extensions.php file where different returns (e.g.: search results/archive/category listing/front page) are spelled out as either $content = 'full' or $content = 'excerpt'
    It appears that anything set to 'full' won't display the post thumbnail, whereas 'excerpts' will.
    How can I set 'full' posts to display a post thumbnail?

    That actually progresses me to a new question: How can I disable the automatic truncating? I also set the "Read more" manually, so I'd like it to NOT automatically chop off content at 55 words (I found in the helpers.php file where the excerpt size is set to 55 words, but changing that value seems to do nothing)
    Thanks for any and all help/hints

    Posted 10 years ago #
  3. middlesister

    First of all you are using a child theme, right? You should not edit any of the thematic core files, any customization is done via filters and hooks in your child theme's functions.php

    The length of the excerpt is not decided by thematic but wordpress itself. But it doesn't really matter since the method is the same. You change it with a filter. Add this code to your functions.php and change the number to the number of words you want instead.

    function new_excerpt_length($length) {
    	return 20;
    add_filter('excerpt_length', 'new_excerpt_length');

    As for the thumbnails, thematic only adds them on the excerpts by default. The same applies here. You can add thumbnails to full post content with a filter

    function add_thumbnails_to_content($post) {
    	if ( has_post_thumbnail() ) {
    		$post = '<a class="entry-thumb" href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '" >' . get_the_post_thumbnail(get_the_ID(), $size, $attr) . '</a>' . $post;
    	return $post;
    add_filter('the_content' , 'add_thumbnails_to_content');

    This will add the thumbnails everywhere, use conditional logic if you only want them on specific parts of your site.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.