- This topic has 14 replies, 3 voices, and was last updated 1 year, 1 month ago by
David.
-
AuthorPosts
-
August 6, 2022 at 1:04 am #2304900
Alain Aubry
Hi
I am trying to create an archive page with 4 columns, masonry, no feature image, first post larger (or highlighted)… up to here I am fine.
I want to display the feature image just in the first (highlighted) post.. just in the first one.
Can you hint me ?Thanks
AlainAugust 6, 2022 at 12:43 pm #2305341Leo
StaffCustomer SupportHi Alain,
I think we can try a CSS solution.
Can you make the featured images display first using the customizer option?
Let me know π
August 6, 2022 at 2:36 pm #2305379Alain Aubry
yes, it displays all of them, you can check it now.
I want to display ONLY the first one, need to be some kind filter.
CSS can do it, but it will be loading them allAugust 6, 2022 at 2:47 pm #2305382Alain Aubry
a filter will allow me to change the appearance by category or something…
August 7, 2022 at 4:02 am #2305643David
StaffCustomer SupportHi there,
try this PHP Snippet:
add_filter( 'generate_featured_image_output', function( $output ) { global $wp_query; if ( is_category() && 0 != $wp_query->current_post ) { $output = ''; } return $output; } );
August 7, 2022 at 6:23 am #2305734Alain Aubry
YES !!!!
I am amazed, it is exactly what I was looking for.
I can even add some other conditions.THANK YOU SO MUCH !!!
β€οΈYou even work on weekends, wow !!!
August 7, 2022 at 6:53 am #2305762David
StaffCustomer SupportGlad to be of help π
August 8, 2022 at 6:11 am #2306696Alain Aubry
Excuse me for re-opening this tread, but I failed to say I am using “Infinite Scroll” in the arquives, so the enabled feature image repeats every 10 posts.
Every 10 post the feature image is enabled. How can I fix this?
Thanks
AlainAugust 8, 2022 at 6:30 am #2306713David
StaffCustomer SupportHmmm…. not sure if this will work but you could try checking if
is_paged()
eg.if ( is_category() && ( 0 != $wp_query->current_post || is_paged() ) ) {
In that example i check if its NOT the first post OR if it is Paged.
August 8, 2022 at 7:27 am #2306781Alain Aubry
Wow !!! You nailed it again !!!
You guys are geniuses, it is exactly that.Thank you so much!.
BTW, in a different place, also an arquive, I want to show every featured images but the first make larger, what would be the filter to use ?
I thought of ‘generate_blog_image_attributes’ but I haven’t been able to make it work…August 8, 2022 at 7:36 am #2306789David
StaffCustomer SupportDo you mean the thumbnails size eg.
full
for first image,medium
for other images ?If so, then this may work:
add_filter( 'generate_page_header_default_size', function( $size ) { if ( is_category('your target category' ) && 0 != $wp_query->current_post ) { $size = 'medium'; } else { $size = 'full'; } return $size; } );
August 8, 2022 at 7:55 am #2306955Alain Aubry
It look interesting, I will try later today. I will give feedback.
Were can I get all the filters of the theme? I am always looking for this crazy configurations …
Thanks
August 8, 2022 at 7:58 am #2306960David
StaffCustomer SupportFilters in the theme…. there are so many, and not a central place in the docs for them all, but some you will find here:
https://docs.generatepress.com/collection/filters/
The rest, either sniff around the templates and functions on our GitHub or ask us π
August 9, 2022 at 2:42 pm #2308292Alain Aubry
Hi David
Thank you so much !
I learned a lot, this filters are amazing !
Thank you for the filter list, I was not aware of that page, now I have a lot read and study !
Big thank you for all the team and Tom of course !
Done.August 10, 2022 at 4:42 am #2308737David
StaffCustomer SupportThank you for the kind words ! We really do appreciate it π
-
AuthorPosts
- You must be logged in to reply to this topic.