- This topic has 11 replies, 4 voices, and was last updated 4 years, 10 months ago by Leo.
-
AuthorPosts
-
October 25, 2016 at 12:22 am #238575Frode
Hi
I added a featured image in a post and it display`s perfect.
The problem is when I visit the blog and click the image I get a pop up of my hole blog above the site.
Than I have to close it by clicking the cross in the right corner.
I do not want that (its not beautiful) and would like to remove the link on the image.How can I fix?
Best Regards
Frode
October 25, 2016 at 10:17 am #238750TomLead DeveloperLead DeveloperIt sounds like you have a plugin added that is making all links around images open a lightbox of their destination.
Good idea if the image is linking to itself or a larger image, not a good idea if it’s linking to another page as the post image does.
I would suggest letting the dev of that plugin know, as this is a bug in their plugin.
Of course, you can remove the link using this function: https://gist.github.com/generatepress/65aff21092a25e5a6f97
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
October 25, 2016 at 11:18 pm #238894FrodeHi
Thanks for helping.
You’re right, it was a nextgen plug in that say true to apply image effect on all images. I set it to apply only too nextgen images.
And now it works.
Thanks
Best regards
Frode
October 25, 2016 at 11:26 pm #238899TomLead DeveloperLead DeveloperYou’re welcome π
June 6, 2019 at 6:46 am #921535SamiIs it possible to get an updated code to this?
It still works to remove the link but it adds some strange classes and the style of the images looks different. I guess it’s because the code is 3 years old and some parts of the theme changed. I tried for a few hours but can’t get a clean result, would be great if you could post an updated version.
June 6, 2019 at 8:50 am #921795LeoStaffCustomer SupportTo remove the featured image link on posts page?
This should work:
https://docs.generatepress.com/article/generate_featured_image_output/#exampleJune 7, 2019 at 12:17 am #922342SamiIt should remove the image links from posts on a CPT archive page and it works perfect, thank you!
Is it possible to still link to certain posts? For example, all posts that have the Taxonomy “linktopost” set to “on”.
I tried to surround your filter with:
if (is_tax('linktopost','on' )) { THE-FILTER }
I also tried “term_exists” and “has_term” but it didn’t work, any idea what I did wrong?
June 7, 2019 at 8:31 am #922760TomLead DeveloperLead DeveloperI think
has_term()
should work. Can you share your full code?June 7, 2019 at 9:24 am #922793SamiSure, this is the code I’ve used:
if (has_term('linktopost','on' )) { add_filter( 'generate_featured_image_output', function( $output ) { return sprintf( // WPCS: XSS ok. '<div class="post-image"> %2$s </div>', esc_url( get_permalink() ), get_the_post_thumbnail( get_the_ID(), apply_filters( 'generate_page_header_default_size', 'full' ), array( 'itemprop' => 'image', ) ) ); } ); }
June 7, 2019 at 9:28 am #922797LeoStaffCustomer SupportWhat if you put the if statement inside?
add_filter( 'generate_featured_image_output', function( $output ) { if (has_term('linktopost','on' )) { return sprintf( // WPCS: XSS ok. '<div class="post-image"> %2$s </div>', esc_url( get_permalink() ), get_the_post_thumbnail( get_the_ID(), apply_filters( 'generate_page_header_default_size', 'full' ), array( 'itemprop' => 'image', ) ) ); } return $output; } );
June 7, 2019 at 10:17 pm #923094SamiThat worked π Thank you for your help!
June 8, 2019 at 7:35 am #923418LeoStaffCustomer SupportNo problem π
-
AuthorPosts
- You must be logged in to reply to this topic.