Disable Featured Images in Twenty Nineteen Theme without CSS
Of course everything is possible to hide with CSS 😁 But it isn’t a solution, is it?
The solution is as simple as a single line of code:
/** * @snippet Disable Featured Images in Twenty Nineteen WordPress theme * @sourcecode https://rudrastyh.com/?p=8383 * @author Misha Rudrastyh */ add_filter('twentynineteen_can_show_post_thumbnail', '__return_false');
This code will hide featured images in:
- Single posts pages,
- Archive pages, like Blog, Categories etc,
- Everywhere where
twentynineteen_post_thumbnail()
function is used to display a post thumbnail.
Where to insert this code? You can create a custom plugin and paste that line of code in it or you can use it in functions.php
file of a child theme (I used this way).
Seems too difficult? Download my plugin.
Of course functions.php
inside Twenty Nineteen theme itself is not recommended, it will work only until the first theme update.
Maybe it is Better to Remove Featured Images from Every Post?
Yep, it is an option too! But what to do if you have hundreds of posts?
Easy-peasy! All you have to do is to run this SQL query in your database phpMyAdmin:
DELETE FROM wp_postmeta WHERE meta_key = '_thumbnail_id';
Should I remind you that you have to always backup your database before running any queries in it? And do not forget to replace the wp_
if you’re using a custom database prefix.