- This topic has 8 replies, 2 voices, and was last updated 3 years, 11 months ago by
Tom.
-
AuthorPosts
-
April 17, 2019 at 2:35 pm #872012
Andreas
I am trying to customize the custom-single.php file (thumbnail) but I am not sure how to access the code for the thumbnail directly.
I only see:
<?php /** * generate_before_content hook. * * @since 0.1 * * @hooked generate_featured_page_header_inside_single - 10 */ do_action( 'generate_before_content' ); ?>
Could you let me know how I can customize the raw code and also what if I like to have the featured image somewhere else on the page. What would be the best approach here be?
Thanks in advance.
GeneratePress 2.2.2GP Premium 1.7.8April 17, 2019 at 3:37 pm #872057Tom
Lead DeveloperLead DeveloperHi there,
The featured image is hooked into the template. Where are you wanting it to be instead?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 17, 2019 at 8:13 pm #872149Andreas
Hi Tom,
thank you very much for your feedback. Yes, I saw the various hooks in the content-single.php template and also the drop-down placement options in the Customizer.
Let’s say I wanted to add code that would show multiple thumbnails in a slider or slightly change the php code for the display of the thumbnails.
Is there any place/file where I could overwrite the current raw thumbnail placement php code non-destructively — meaning it would not be overwritten in a generatepress theme update or what would you suggest would be the best approach for such a case?
Thanks in advance for your help!
April 18, 2019 at 9:01 am #872767Tom
Lead DeveloperLead DeveloperYou can unhook the current featured image:
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
Then you can add your own:
add_action( 'generate_before_content', function() { if ( is_single() ) { the_post_thumbnail(); // Or whatever you need to do. } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 18, 2019 at 10:59 am #872845Andreas
Hi Tom,
thanks for the helpful and knowledgeable answer – would I add these code snippets in the content-single.php file or the global functions.php file?
Thanks agin and I am looking forward to trying this out!
April 18, 2019 at 1:23 pm #872948Andreas
Hi Tom,
I tested your code snippets putting them in the functions.php file of the child theme and the add_action works but the remove_action does not work.
The customizer has the featured image for ‘Post’ set to ‘Below Title’ so I changed your remove code to:
remove_action( 'generate_after_entry_title', 'generate_featured_page_header_inside_single', 10 );
and:
remove_action( 'generate_after_entry_header', 'generate_featured_page_header_inside_single', 10 );
and also:
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
but neither of these were able to remove the Featured Image on the Single Post page.
If you could double-check what the issue might be that would be great.
Thank you!
April 18, 2019 at 4:16 pm #873050Tom
Lead DeveloperLead DeveloperTry this instead:
add_action( 'wp', function() { remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' ); }, 100 );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 18, 2019 at 6:44 pm #873099Andreas
Hi Tom,
yes, this one worked like a charm – thanks so much.April 19, 2019 at 8:40 am #873611Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.