1

I found this solution to getting the featured image to default below the post title. wordpress add featured image below post title

Where do I place this php?

Will it work for all posts?

1 Answers1

0

Please have a look at the wordpress template hierarchy in themes:

https://developer.wordpress.org/themes/basics/template-hierarchy/

You can edit the look of single post views inside the single.php, if using a custom post type single-{post-type}.php. If you are using a theme that is not made by yourself and might get updated, make sure to use a child theme, so your changes will not be overwritten when the parent theme is getting updated.

This is a nice tutorial for creating child themes in wordpress: https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/

In the template file you get the featured image with get_the_post_thumbnail() function and the post title with get_the_title() function.

Search for the lines in the code, where you can find the functions and change the location to your desired place. Or if there is no featured image, you can add the code you already found.


Where do I place this in php?

Inside of the single page template of your theme.

Will it work for all posts?

If you use the single.php file, yes. All posts use this template. But you can only apply the changes to specific post types as described above - if you like to. You can also make it work for some specific category terms with category-{term}.php or maybe you want to change the post listing in your archive.php. Please check the link above, Wordpress Template Hierarchy will make this clear, very easy to understand.

Hope this helps!

rank
  • 2,361
  • 2
  • 10
  • 20
  • Thank you for your detailed and helpful answer. To confirm, can I place this code in single.php of my theme to get the featured image below the title? '; the_post_thumbnail('thumbnail'); echo ''; } – Andrew Jordan Jun 02 '20 at 17:22
  • This is seems to be ok at first sight, but you can just try if the code works? If not, what are the errors saying? To tell you, if it is below the title, you have to give me more code, at least where you output the title ;) So I get see if it is below or above. – rank Jun 03 '20 at 08:00