Hi there,
our plugin can currently only add links, but it cannot modify texts.
You can create a custom solution for the functions.php
file, for example, something like this:
function add_star_to_specific_affiliate_links($content) {
// Search for links with
data-internallinksmanager
and only modify their text
$pattern = '/<a([^>]*data-internallinksmanager[^>]*)>(.*?)<\/a>/i';
$replacement = '<a$1>*$2</a>';
// Replace only the desired links
$content = preg_replace($pattern, $replacement);
return $content;
}
// Filter to modify the content of the posts
add_filter('the_content', 'add_star_to_specific_affiliate_links');
Explanation of the Code
Pattern:
([^>]*data-internallinksmanager[^>]*)
: Searches for <a>
tags that contain data-internallinksmanager
. The hash is covered by [^>]*
(any characters until the tag end).
(.*?)
: Searches for the text within the <a>
tag.
Replacement:
- The asterisk
*
is added only before the link text ($2
).
Filter:
- The code targets the content of the posts and modifies only the desired links.
Please consider: This is a untested example. Test the code in a development environment first before using it in a live environment.