Hi techlector
Try it with these filters.
Put this in your (child) theme’s functions.php file:
add_filter('related_posts_by_taxonomy_post_link','add_analytics_to_related_posts', 10,3);
function add_analytics_to_related_posts($link, $post, $attr ) {
$analytics = 'your-analytics-string-here';
// Link for posts
$link = "<a href='{$attr['permalink']}?analitics={$analytics}'>{$attr['title']}</a>";
return $link;
}
add_filter('related_posts_by_taxonomy_post_thumbnail_link','add_analytics_to_related_posts_thumbnails', 10,4);
function add_analytics_to_related_posts_thumbnails( $link, $attr, $post, $args ) {
$analytics = 'your-analytics-string-here';
// Link for post thumbnails
$link = "<a href='{$attr['permalink']}?analitics={$analytics}'>{$attr['thumbnail']}</a>";
return $link;
}
btw:
consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.
-
This reply was modified 5 years, 10 months ago by keesiemeijer.