• Hi all,

    Would really appreciate some help on this one as I’ve been struggling with it a while now.

    I’m trying to get the post thumbnail (featured image) to appear next to only the excerpt on the home page, archive pages, and category pages.

    I’ve read through the wordpress codex on the_post_thumbnail() here https://codex.www.ads-software.com/Post_Thumbnails and countless other guides but still cannot figure out where to put the ‘the_post_thumbnail()’ code in order to get it to show on the home page.

    I’m using twentyten theme.

    Thanks

Viewing 15 replies - 1 through 15 (of 21 total)
  • Don’t edit the Twenty Ten theme. Your changes will be over-written the next time you upgrade WordPress. For this reason, it is recommended that you consider creating a child theme for your customisations. Once your child theme is active, we should be able to help with the customisation.

    Thread Starter davede

    (@davede)

    Ah thanks – I wasn’t aware of that at all.

    What I’ve actually done is take the twentyten theme and customize it so that it fits with the rest of our site. I created a completely new set of files and labelled the theme something else.

    Is this considered a child theme? Will it be safe to update without the theme being overwritten?

    Also I think I may have solved the post thumbnail problem by putting using the following code in the loop.php file:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    It seems to work however I’m open to other suggestions if there is a better way.

    Thread Starter davede

    (@davede)

    The wordpress part of our site is here if it will help:

    Money & Investment Guides

    Moderator keesiemeijer

    (@keesiemeijer)

    If you only changed the directory name of the twenty ten theme it’s not considered a child theme. But it will not be over-written the next time you upgrade WordPress. To make it a child theme you have to put this on top of your theme’s stylesheet style.css (the only required template file for a child theme):

    /*
    Theme Name:     Twenty Ten Child
    Template:       twentyten
    */

    this stylesheet replaces the style.css of the parent twentyten style.css.

    You can inport the css rules of twentyten by inporting it.

    /*
    Theme Name:     Twenty Ten Child
    Template:       twentyten
    */
    @import url("../twentyten/style.css");

    Thread Starter davede

    (@davede)

    ah ok… thank you very much for that.

    so the entire custom theme is in another directory. there have clearly been extensive edits to the style.css.

    will adding your suggested code at the top require any additional changes or screw anything up at all?

    Moderator keesiemeijer

    (@keesiemeijer)

    You don’t need to make it a child theme if you don’t want to. This is only useful when twentyten or any other theme will update it’s theme with changes or new functionallity in future update’s. You can then savely install the updated theme and still have the modifications you made.

    Try it with importing the twentyten stylesheet and see if it screws anything up.

    Functions.php could be a problem file because it is loaded in addition to the parent’s (twentyten) functions.php. (Specifically, it is loaded right before the parent’s file.)

    Thread Starter davede

    (@davede)

    ok,

    I’m a little confused on this topic so I’ll check out the codex.

    I suppose this is important as I was planning on building a theme for another project and basing it on the twentyten theme.

    Thanks for your help.

    https://vudu.me/child
    Hopefully that may be helpful to you in learning about a child theme vs. a new theme

    Thread Starter davede

    (@davede)

    Voodoo,

    I read through the guide you posted. Great stuff!!!

    Looks like we had inadvertently chosen option one when trying to make our theme based on our non-wordpress site component.

    Thank you very much.

    As usual I’ve gotten a bit side tracked here but back to the original topic. I’m now having a conflict with the AddThis plugin and the post thumbnails. I’ve started a new thread on it in the plugin area here: https://www.ads-software.com/support/topic/addthis-plugin-and-post-thumbnail-conflict?replies=1#post-2166317

    Also am I right in saying that the sizes of the post thumbnails can only be set when the file is uploaded e.g. if you chance the size parameters after uploading the file the size will not change?

    Moderator keesiemeijer

    (@keesiemeijer)

    Thread Starter davede

    (@davede)

    Thanks so much for that kees,

    It seems though that if I upload an image without having set the thumbnail size prior to uploading I can’t change the size afterwards.

    e.g.

    I upload an image and set it as a featured image. Then go into loop.php and set the size parameters for the post thumbnail. There will is no effect on the size of the featured image that i uploaded.

    should this be happening?

    Are the size parameters passed to it only when it is uploaded?

    Moderator keesiemeijer

    (@keesiemeijer)

    Thread Starter davede

    (@davede)

    ok thanks again,

    I’ve read through it and actually was using the add image size function already (seems my code got deleted in an earlier post).

    In my functions.php I’ve got:

    add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 150, 150, true );
    	add_image_size( 'category-thumb', 200, 9999 );

    and in the loop.php i’ve got:

    <?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      				the_post_thumbnail('category-thumb');
    				}
    				?>

    Is it maybe the set_thumbnail_size that is messing it up?

    Are you trying to say that I can control the size of the post thumbnail at a later stage by editing the add_image_size size parameters and keep the same name?

    Moderator keesiemeijer

    (@keesiemeijer)

    AJAX thumbnail rebuild – This plugin allows you to re-build the post thumbnails. Useful if you use add_image_size() after already having uploaded post thumbnails. (This plugin is slow, but never has out of memory errors).

    Thread Starter davede

    (@davede)

    That confirms exactly what I was trying to figure out.

    Looks like a very valuable plugin indeed.

    Thank you so much kees you’ve been a massive help!

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Post Thumbnail / Feature Image Next To Excerpt’ is closed to new replies.