Ad Code

Featured Image Inside WordPress Post

As some one asked me how to show featured image in WordPress post?. Because featured image tells the topic as well as it helps you to make your page looks clear and good looking.

Read the documentation how templates of WordPress works and how it designed. Here is the link of how WordPress defined the featured image the documentation and whole bunch of functionalities.

WordPress Documentation about Featured Image

Enable Featured Image Support in Theme:

Some old themes do not support featured image and you have to add the functionality using the function.php located in your theme main folder.
  • Login to your Dashboard then go to Appearance.
  • Click on Editor and on the right sidebar click on functions.php file.
  • At the end of the file place this code.
if ( function_exists( 'add_theme_support' ) )
{
add_theme_support( 'post-thumbnails' );
}


Above code will add the functionality. If it does not exist. After that you have to add the functionality to your theme the post thumbnail size on which dimension WordPress  crop the images. Be Careful.

Read Detailed Post on Featured Image and Post Thumbnail


Setting Post Thumbnail Sizes

WordPress write itself their documentation about setting post thumbnail size and can be done using functions.php file according to them

Read the WordPress Documentation of Set_Post_Thumbnail_Size

We are just try to display post thumbnail in our single.php file find the code the_content() in your single.php file. Write just above it

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

Read the WordPress Documentation on The_Post_Thumbnail
Reactions

Post a Comment

0 Comments