Home › Forums › Support › Hide featured image under some conditions This topic has 9 replies, 2 voices, and was last updated 3 years, 3 months ago by Leo. Viewing 10 posts - 1 through 10 (of 10 total) Author Posts December 2, 2020 at 1:24 pm #1564515 webintas Hi there, In some specific cases I want to remove the featured image. I have tried the code below but that does not work. How to do it? add_action( ‘wp’,’generate_remove_featured image’ ); function generate_remove_featured () { if (is_single(1256)){ remove_action(‘generate_before_content’,’generate_featured_page_header_inside_single’, 10); } } December 2, 2020 at 1:26 pm #1564517 LeoStaff Customer Support Hi there, In some specific cases I want to remove the featured image. Can you let me know what those cases are? December 2, 2020 at 2:58 pm #1564668 webintas It depend on whether a custom field is filled out the the backend. I offer the bloggers an opportunity to insert a YouTube video instead of the featured image. If they do, I need to remove the featured image from single. December 2, 2020 at 7:17 pm #1564867 LeoStaff Customer Support Would the disable element metabox help? https://docs.generatepress.com/article/disable-elements-overview/ You can also create a layout element for it: https://docs.generatepress.com/article/layout-element-overview/#disable-element December 3, 2020 at 1:09 am #1565166 webintas We are on the right track with the disable elements option. But is it possible to do it from the PHP code? December 3, 2020 at 8:45 am #1566069 LeoStaff Customer Support Your function names need to match: https://www.screencast.com/t/9DsxqVtUvw9Z And the syntax for is_single need to be corrected as well: https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page December 3, 2020 at 12:15 pm #1566328 webintas Wauw.. How could I miss that. However, it did not help. I have tried to clean up and keep it simple: add_action('wp','generate_remove_featured'); function generate_remove_featured () { remove_action('generate_before_content','generate_featured_page_header_inside_single', 10); } That does not work either. December 3, 2020 at 1:02 pm #1566403 LeoStaff Customer Support Is the Blog module activated? If so try this filter instead: https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98single_post_image%E2%80%99 Example: add_filter( 'option_generate_blog_settings', function( $options ) { if ( is_single( '17' ) ) { $options['single_post_image'] = false; } return $options; } ); December 4, 2020 at 11:07 am #1567713 webintas Thanks ! That helped ๐ December 4, 2020 at 11:20 am #1567728 LeoStaff Customer Support No problem ๐ Author Posts Viewing 10 posts - 1 through 10 (of 10 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In