2

I'm new to WordPress development. I watched a video on how to add featured images. For some reason it's not working, and I can't really figure out why. The option for featured image is not showing at all. So I don't really know how to fix it.

I've tried Googling to see if people have experienced the same thing. From what I've seen, it's usually syntax errors. However, I don't think I have that.

  • I've tried deleting and adding it on again, but to no avail.
  • I've also tried adding an array as a second argument to add_theme_support, but still nothing.
  • I've also tried having the add_actions function before the custom function. That hasn't worked either.
  • In addition to that, I tried just having the add_theme_support without the add_action, but again nothing.

Here is the code in the functions.php file:

`add_action( 'after_setup_theme', 'Image_theme_setup' );
function Image_theme_setup() { 
    add_theme_support( 'post-thumbnails' ); 
}`

2 Answers 2

1

First of all, I like to know that you are using a custom post type and in that you want to add featured image support, if yes then you need to write extra code in functions.php of theme.

$post_type_name  = new Cuztom_Post_Type( 'your-custom-post-type', array(
'supports' => array('thumbnail')

));

1

WordPress editor will add the option to add featured image to your posts, when you add code like the following in the theme's functions.php file:

add_action( 'after_setup_theme', 'theme_featured_image_setup' );
function theme_featured_image_setup() { 
    add_theme_support( 'post-thumbnails' ); 
}

Note: make sure you didn't include the back-ticks (``) with the code. Sometimes copying code from the web causes small issues like that.

So unless you've made an error somewhere in your code, the editor option should show up. So:

  • Make sure you've activated the correct theme.
  • Make sure your functions.php file has the correct file name.
  • Make sure your functions.php file has no error in the code. You may provide the full functions.php code exactly as it is, for someone to take a look at. But before that, check PHP error log to see if it's generating any error.

Also, after you've done everything correctly, you must add the following function call in a theme template file (for example in single.php), for the featured image to show up in the frontend:

the_post_thumbnail();

I can't think of any other reason why it shouldn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.