This is very simple to achieve with JavaScript. Place this at the bottom of your page, just before </body> tag.
This will append ?pp=my-affiliate-id at the end of your links. Just change the variable aid value below:
<script>
// Change "my-affiliate-id" below to your actual affiliate id
const aid = 'my-affiliate-id';
// Append slash with affiliate id, only if an affiliate ID is not found in the link yet
const goglinks = document.querySelectorAll('a[href*="gog.com"]');
goglinks.forEach(function(el) {
if(!el.href.includes('pp=')) {
el.href = el.href.replace(/\?.*$/, '') + '?pp=' + aid
}
})
</script>
Related Posts:
- Menu Link Redirect Based on Username or User ID
- how to get permalink
- How to use relative links on my pages?
- How can I store page ID in a post instead of other selected permalink?
- How to get a page url by a page id?
- Why does WP not use relative links when linking pages?
- Social Media Links on homepage – within posts/post loop
- Change website URL without breaking links or images? WP 3.3
- Redirect user if it’s not logged in
- How to get this JavaScript working with get_permalink
- WordPress 3.1 not compatible with jQuery Mobile?
- I copied my site to another site but all links point to old site
- Best way to add internal link in widget
- Confusion about how a URL is being parsed
- Change in permalink structure made javascript cookie not work correctly
- why some permalinks adding characters/ruining links
- How to change old permalink?
- Migrated from Windows to Linux. Any bulk methods for fixing case sensitivity?
- How to eliminate permalink prefix in WordPress Multisite
- Get the url of a page template without using the page slug and ID
- How to generate a list of all urls
- Format HTTP links
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- Can WP give a value a post ID?
- Moved site, Old links in pages still pointing to old host
- How to use page jumps to top of banner and page title?
- How to remove the link of an image on WP 4.2
- Create custom links for excerpts with php dynamically
- How can I see a list of all pages my WordPress site has generated?
- How to make different urls for some tags pages
- Gutenberg Editor: dynamically edit slug field based on ACF field
- A dash can replace a period in a link, how to fix it
- Edit Post Permalink option removed, looking for possible causes
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- Can I link to content dynamically from a page to a new page?
- Propper way to set anchor and url param
- Find internal links to post
- rebuilding/ rewriting a url to make it SEO friendly
- Remove link function from oembed image or video
- How to change dynamic link to relevant post
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Possible to hide parts of the slug from get_template_directory_uri and bloginfo(‘template_directory’)
- After changing permalink settings, everything works fine except for the two most recent posts
- Latin character conversion
- Why not working /%postname%/ with ajax serverinterval?
- Pretty links for PHP pages above WP /blog directory?
- Permalink / sub-template issue
- Permalink structure as code in back-end?
- Include other parameters in permalinks for better management of browser history
- What is the issue with our links? It creates a loop
- wp_get_attachment_url not working
- Make all internal links relative, or otherwise make a website accessible from multiple domains
- Can you customize the automatic permalink population on new posts?
- How do I disable the changing of the permalink for published posts (for non-admin)?
- Toggle show/hide on click with jQuery
- querySelector vs. getElementById
- How to generate a simple popup using jQuery
- When is JavaScript synchronous?
- How to reset a form using jQuery with .reset() method
- Load image with jQuery and append it to the DOM
- What is the non-jQuery equivalent of ‘$(document).ready()’?
- Changing the selected option of an HTML Select element
- jQuery in header or footer
- How to prevent the default home rewrite to a static page
- WordPress Ajax always returns a 404 error
- How to get url of a post from admin panel
- Modify Custom Field in Media Library using JavaScript
- CPT archive 404ing when using a custom taxonomy name as a variable
- Performance and styles not working fine after changing permalink structure
- Maintaining two permalink structures
- removing index.php IIS 7.5 webconfig
- Permalinks Messed up
- How to 301 all posts
- WordPress within specific sub-directories, implicitly not root
- combining js scripts from a js newb [closed]
- Is there anything built into the WordPress core to enable me to get the relative path from the “permalink structure” option
- Permalink change made author archive vanished
- Ajax load more button for comments wordpress
- Process all virtual sub pages on parent page
- Custom permalink with two parameters
- home_url on IIS missing permalink index.php
- Remove Parents From Permalink of Hierarchical Taxonomy
- Default Permalink Structure for Pages
- Problems fixing a REST API 404 after Moving my WordPress Directory and updating Permalink Structure
- Edit the output of a filter
- Can’t Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM
- Custom Permalink Structure for The Events Calendar
- How to echo a PHP code into WooCommerce variation product?
- how to have same rewrite rules for 2 different post type?
- How can I add my own ‘read more’ or ‘after the jump’ type of link to the article page?
- How to change permalink structure and keep permalinks for old posts
- Is there a way to remove the option to modify the Slug in post.php
- Issues with WordPress permalinks
- Mystery ghost page not appearing in Admin
- Update permalinks after domain change
- Comparing permalink to url
- Element works, but not on wordpress site [duplicate]
- Add segment to URL in htaccess
- Facebook like button disappears after changing the static permalink to dynamic one!