Title: featured image in post title
Last modified: August 21, 2016

---

# featured image in post title

 *  Resolved [steven-stallone](https://wordpress.org/support/users/steven-stallone-1/)
 * (@steven-stallone-1)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/)
 * I’ve been constantly jumping hoops to try and get my wordpress site to the way
   I want it.
 * At the moment I am using the “unstandard” theme. I don’t think it’s supported
   but I had reasons for choosing it.
 * The problem is I am trying to insert a featured image (or any banner type image)
   where the title of the post is. Featured images in wordpress are quite confusing.
   I uploaded a featured image which displays fine on the home page but the same
   featured image doesn’t display in the post. In some themes this is built in but
   it’s not built in on my theme. I found code that replaces any text in the title
   area of the post with the featured image of the post. I thought my problems were
   solved until the post only displays a portion of the image, which you can see
   here…
 * [http://www.stevenstallone.com](http://www.stevenstallone.com)
 * [http://www.stevenstallone.com/2013/04/10/diddy-kong-reloaded/](http://www.stevenstallone.com/2013/04/10/diddy-kong-reloaded/)
 * What makes no sense with featured images is that it can somehow display the full
   image on the homepage and yet somehow display the same image cropped for no reason.
   I don’t know what to call this, whether it’s a thumbnail or if it’s not a thumbnail
   any more and it’s now called a featured image. This cropping makes no sense. 
   So I adjusted the size of the thumbnail of the thumbnail? of the picture in the
   media setting and this does nothing. WordPress is just happy to display the image
   cropped. Here is the text that was used to replace the title(); in single.php
 *     ```
       <h2><?php
           if ( has_post_thumbnail() ) {
           // check if the post has a Post Thumbnail (featured image) assigned to it.
               the_post_thumbnail();
           } else {
               the_title();
           }
       ?></h2>
       ```
   
 * I’ve read through a few solutions, some out of date and this is the closest I’ve
   got to something working.
 * What I am looking for ideally is to be able to set the featured image into the
   title section of the post with or without the title text as well, whether the
   text be above or below image. Also I’m looking for the ability to put in a custom
   image/banner into the post title that is completely different to the set featured
   image that displays on the home page.
 * I want to have all my avenues of customability sorted just in case down the line
   I want to put either a title and image, featured image alone, non featured image
   alone, etc…
 * Feel free to relax by watching the “Diddy Kong Reloaded” video on my website.
 * Thanks in advance…

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3694799)
 * What are the specific dimensions of the featured image that you want to display
   with/in place of the post title?
 *  Thread Starter [steven-stallone](https://wordpress.org/support/users/steven-stallone-1/)
 * (@steven-stallone-1)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3694816)
 * The width of the single column. That’s the same width as the embedded YouTube
   clip which is 700.
 * I edited the first post to fix the link but it never saved
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3694832)
 * > The width of the single column. That’s the same width as the embedded YouTube
   > clip which is 700.
 * Okay, I’ll assume that you don’t care about height, but only width.
 * In that case, add the following to `functions.php`:
 *     ```
       function stevenstallone_add_custom_image_size() {
           add_image_size( 'post-title', 700, 9999, false );
       }
       add_action( 'after_setup_theme', 'stevenstallone_add_custom_image_size' );
       ```
   
 * That function will register a custom, featured-image size. The 700 is the width,
   in pixels. The 9999 is height, in pixels. The `false` indicates that the cropping
   will be a “soft” crop, i.e. “box resize”: it will resize the image using the 
   constraining dimension. So, if you have an image that is 1400x200px, it will 
   be resized to 700x100px.
 * But, just registering that size isn’t enough, as any already-uploaded images 
   won’t have that size generated. So, you’ll need to regenerate thumbnails, e.g.
   via the [Regenerate Thumbnails Plugin](http://wordpress.org/extend/plugins/regenerate-thumbnails/).
 * That Plugin will force WordPress to regenerate intermediate image sizes for all
   uploaded images. Afterward, you’ll be able to reference/use your custom image
   size.
 * Next, you need to modify the template. You were on the right track before:
 *     ```
       <h2>
       <?php
       if ( has_post_thumbnail() ) {
           the_post_thumbnail( 'post-title' );
       } else {
           the_title();
       }
       ?>
       </h2>
       ```
   
 *  Thread Starter [steven-stallone](https://wordpress.org/support/users/steven-stallone-1/)
 * (@steven-stallone-1)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3694840)
 * Ah thank you, it sounds like it will work but I don’t have time to play with 
   it now. I’ll check it out tomorrow, thanks
 *  Thread Starter [steven-stallone](https://wordpress.org/support/users/steven-stallone-1/)
 * (@steven-stallone-1)
 * [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3695048)
 * Ok, I figured out why the image was cropping. Firstly I tried the solution above
   and It had no effect. What I didn’t realize that there was additional coding 
   I was unaware of in the functions.php which limited any featured image in any
   post to just 200, 200. So there was already code to handle featured images already.
   I just didn’t realize it. The solution wasn’t needed after all but I did learn
   my first insight about php and that was the ‘true/false’ values
 * **Origional**
 *     ```
       add_theme_support( 'post-thumbnails' );
       set_post_thumbnail_size( 200, 200, true );
       add_image_size( 'primary-post-thumbnail', 620, 9999 );
       add_image_size( 'secondary-post-thumbnail', 300, 9999 );
       ```
   
 * In the original I changed the first value from 200 to 700 but the image wouldn’t
   crop to width but to height then I remembered the explanation of why the value
   was set to false in the solution above. That is the switch for the width to take
   precedence. So then I modified the original code to 700, 9999, false. and it 
   worked.
 * **Modified**
 *     ```
       add_theme_support( 'post-thumbnails' );
       set_post_thumbnail_size( 700, 9999, false );
       add_image_size( 'primary-post-thumbnail', 620, 9999 );
       add_image_size( 'secondary-post-thumbnail', 300, 9999 );
       ```
   
 * Thanks Chip

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘featured image in post title’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [steven-stallone](https://wordpress.org/support/users/steven-stallone-1/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/featured-image-in-post-title/#post-3695048)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
