WPIntell

Source evidence

affiliate addd * star before text?

Internal Links Manager · support · 2024-11-24T16:15:00+00:00

questionsentiment
highseverity
0.95relevance
3replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 34 rows with source links

14.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
jenomal resolved
Hello, I just installed your plugin on my website and need help setting up affiliate links/URLs. For example, I added a URL for the Amazon Affiliate Program. Now, I want a star (*) to be automatically inserted before every word that I highlight. How can I achieve this? 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. thank you for your reply and the code. unfortunatelly it does not work. it says “fatal error.” this ocde did what i want: function add_custom_css() { ?> <?php } add_action(‘wp_head’, ‘add_custom_css’);

Comments

3 shown
webraketen 2024-11-25T17:03:00+00:00

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.

jenomal 2024-11-25T17:34:00+00:00

thank you for your reply and the code. unfortunatelly it does not work. it says “fatal error.”

jenomal 2024-11-26T06:09:00+00:00

this ocde did what i want: function add_custom_css() { ?> <?php } add_action(‘wp_head’, ‘add_custom_css’);