- This topic has 9 replies, 2 voices, and was last updated 5 years, 4 months ago by
Leo.
-
AuthorPosts
-
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 #1564517Leo
StaffCustomer SupportHi 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 #1564668webintas
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 #1564867Leo
StaffCustomer SupportWould 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-elementDecember 3, 2020 at 1:09 am #1565166webintas
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 #1566069Leo
StaffCustomer SupportYour function names need to match:
https://www.screencast.com/t/9DsxqVtUvw9ZAnd the syntax for is_single need to be corrected as well:
https://codex.wordpress.org/Conditional_Tags#A_Single_Post_PageDecember 3, 2020 at 12:15 pm #1566328webintas
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 #1566403Leo
StaffCustomer SupportIs 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%99Example:
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 #1567713webintas
Thanks ! That helped 🙂
December 4, 2020 at 11:20 am #1567728Leo
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.