Hi Support-team,
We try to find a solution to change the link of a Post Image on Post-Archive from a link to Autor-Page to the blogpost. Same link like the link on the title. Is there a hook to get that?
Thanks for Four your help
Tobias
Hey Tobias,
Please try the author_link filter in your functions.php:
// redirect author link
add_filter( 'author_link', 'modify_author_link', 10, 1 );
function modify_author_link( $link ) {
$link = 'http://example.com/';
return $link;
}
Please adjust the url to suit.
Best regards,
Mike
Hi Mike,
thanks thats a nice hook. But we looking for a solution to change only the Link from the featured image. the link should go to blogpost and not to author page.
Is there another hook to change that?
Thanks for your answer
Tobias
Hi,
Will all of the featured images going to link to the same site or page or does each need to be a different link?
Best regards,
Mike
Hi Mike,
each to a different post. The same link like the link of the post title.
Thanks for your help.
Tobias‘
Hi,
I didn’t find a filter for it but I did write this javascript to replace the image url with the title url.
Try adding this code to the end of your functions.php file in Appearance > Editor:
function archive_img_link(){
?>
<script>
(function($){
$(document).ready(function(){
$(".entry-content-wrapper").each(function(){
var posturl = $(this).find("h2.post-title.entry-title a").attr("href");
$(this).find(".big-preview.multi-big a").attr("href", posturl);
});
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'archive_img_link');
Please give this a try and also check other pages and posts for conflicts.
Best regards,
Mike
THANK YOU VERY MUCH MIKE!
That works great!
Tobias