WordPress.org

Ready to get started?Download WordPress

Forums

set_post_thumbnail_size() problems (4 posts)

  1. olofiano
    Member
    Posted 1 year ago #

    Hi, I've been googling and searching the forums for the answer why this doesn't work but all of the solutions I've found hasn't worked.

    What I'm trying to do is to set a thumbnailsize of 225x225 pixels with hard crop and what I've tried is the following:

    In my themes function.php I've added:

    add_image_size( 'my-thumb-size', 225, 225, true);
    if ( function_exists( 'add_theme_support' ) ) {
    	add_theme_support( 'post-thumbnails' );
            set_post_thumbnail_size( 225, 225, true );
    }

    In my template I've tried calling the_post_thumbnail() like this:

    the_post_thumbnail('my-thumb-size');
    the_post_thumbnail()
    the_post_thumbnail('post-thumbnails')
    the_post_thumbnail( array(225,225) )

    but neither works. When using just the the_post_thumbnail() tag i get images of size 125x125 which is the default thumbnail size in the media upload section, but this however differs from the one set in media settings. I've also been changing the default sizing in the media settings but this didn't work either and finally I went for the approach found here in desperation but no luck with that either.

    Anyone know what I'm doing wrong? I'm developing my own theme so changing isn't really an option.

    Thanks

    /Olof

  2. wisock
    Member
    Posted 1 year ago #

    how to set single thumbnails ? i need help,please help me, thank you.

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    As per the Forum Welcome, please post your own topic. Posting in a 4 month old existing topic prevents us from being able to track issues by topic. Added to which, your problem - despite any similarity in symptoms - is likely to be completely different.

  4. viky081
    Member
    Posted 1 year ago #

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

    Try like this and let us know if any...

Topic Closed

This topic has been closed to new replies.

About this Topic