Affiliate Link Inserter
A simple but powerful WordPress plugin that automatically inserts affiliate links into your content based on keywords, with CSV bulk import/export, SEO optimization, and easy management features. Author: Dorien Vibecodes.
by Dorien Vibecodes · github.com/tandivina/affiliate-link-inserter · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/tandivina/affiliate-link-inserter/archive/refs/heads/main.zipRequires: WordPress 5.0 or higher
Tested up to: WordPress 6.8
Stable tag: 1.0.0
License: GPL v2 or later
Short Description
Automatically inserts saved affiliate links into your articles based on keywords with advanced targeting and CSV import/export capabilities.
Description
Affiliate Link Inserter is a powerful WordPress plugin that automatically inserts your saved affiliate links into articles you publish. The plugin intelligently matches keywords in your content and replaces them with properly formatted affiliate links, helping you monetize your content effortlessly while maintaining SEO best practices.
Features
🚀 Automatic Link Insertion
- Automatically replaces keywords with affiliate links in your posts
- Smart keyword matching with configurable options
- Control maximum links per post to avoid over-optimization
🎯 Advanced Targeting
- Case-sensitive or case-insensitive matching
- Whole word matching to avoid partial replacements
- Exclude specific content types (pages, home page)
- Position control (first occurrence, all occurrences, random)
🛠️ Easy Management Interface
- User-friendly admin dashboard
- Add, edit, and delete affiliate links with ease
- Real-time search and filtering
- Bulk status management (activate/deactivate links)
- CSV Import/Export for bulk operations
- Download template for easy setup
📊 SEO Optimized
- Automatic "nofollow sponsored" attributes
- Customizable rel attributes for each link
- Link text customization
- CSS class support for styling
⚙️ Flexible Configuration
- Global settings for insertion behavior
- Per-link settings for maximum insertions
- Performance statistics and monitoring
- Import/export capabilities (coming soon)
Installation
Method 1: Upload via WordPress Admin
- Download the plugin files
- Create a zip file containing all plugin files
- Go to WordPress Admin → Plugins → Add New
- Click Upload Plugin and select your zip file
- Click Install Now and then Activate
Method 2: FTP Upload
- Download and extract the plugin files
- Upload the entire
affiliate-link-inserterfolder to/wp-content/plugins/ - Go to WordPress Admin → Plugins
- Find "Affiliate Link Inserter" and click Activate
Method 3: Manual Installation
- Copy all files to your WordPress plugins directory:
/wp-content/plugins/affiliate-link-inserter/ - Ensure the main plugin file is:
affiliate-link-inserter.php - Activate the plugin from the WordPress admin
Quick Start Guide
1. Access the Plugin
After activation, find Affiliate Links in your WordPress admin menu.
2. Add Your First Affiliate Link
- Click Add New Link
- Enter a Keyword (e.g., "best headphones")
- Paste your Affiliate URL
- Configure options (optional):
- Custom link text
- Maximum insertions per post
- Target window setting
- CSS classes
- Click Save Link
3. Configure Settings
Go to Affiliate Links → Settings to customize:
- Enable/disable automatic insertion
- Set maximum links per post
- Choose content types to include/exclude
- Configure keyword matching behavior
4. Publish Content
Create or edit posts/pages with your keywords. The plugin will automatically insert affiliate links when the content is displayed.
Plugin Structure
affiliate-link-inserter/
├── affiliate-link-inserter.php # Main plugin file
├── assets/
│ ├── admin.js # Admin JavaScript
│ └── admin.css # Admin styling
├── templates/
│ ├── admin-page.php # Main admin interface
│ └── settings-page.php # Settings page
└── README.md # This file
Usage Examples
Basic Keyword Replacement
- Keyword: "best smartphones"
- Affiliate URL: "https://amazon.com/dp/B08N5WRWNW?tag=yourcode"
- Result: Text "best smartphones" becomes a clickable affiliate link
Custom Link Text
- Keyword: "iPhone 14"
- Link Text: "Latest iPhone (Amazon)"
- Result: "iPhone 14" in content becomes "Latest iPhone (Amazon)" link
Advanced Targeting
- Keyword: "gaming laptop"
- Max Insertions: 2
- Position: First occurrence
- Result: Only the first 2 instances of "gaming laptop" become links
Bulk Import via CSV
- Click "Import CSV" in the admin interface
- Download the CSV template
- Fill in your affiliate links data:
keyword,affiliate_url,link_text,target,rel_attributes,css_class,max_insertions,status best laptop,https://amazon.com/dp/B08N5WRWNW?tag=yourcode-20,Top Laptop,_blank,nofollow sponsored,affiliate-tech,3,active coffee maker,https://amazon.com/dp/B077JBQZPX?tag=yourcode-20,Best Coffee Maker,_blank,nofollow sponsored,,2,active - Upload and import your CSV file
Configuration Options
Global Settings
| Setting | Description | Default |
|---|---|---|
| Enable Insertion | Turn automatic insertion on/off | Enabled |
| Max Links per Post | Maximum affiliate links per post | 5 |
| Exclude Pages | Skip static pages | Disabled |
| Exclude Home | Skip home page | Enabled |
| Case Sensitive | Match exact case | Disabled |
| Whole Words Only | Match complete words only | Enabled |
Per-Link Settings
| Setting | Description | Default |
|---|---|---|
| Keyword | Text to replace | Required |
| Affiliate URL | Your affiliate link | Required |
| Link Text | Display text (optional) | Uses keyword |
| Target | Link target window | _blank |
| Rel Attributes | SEO attributes | nofollow sponsored |
| CSS Class | Custom styling class | None |
| Max Insertions | Per-post limit | 3 |
| Status | Active/Inactive | Active |
CSV Import/Export
📥 Bulk Import
Save time by importing multiple affiliate links at once using CSV files.
How to Import:
- Access Import: Go to Affiliate Links → Manage Links
- Click "Import CSV" button
- Download Template: Click "CSV template file" link
- Fill Template: Add your affiliate links data
- Upload: Select your completed CSV file and click "Import Links"
CSV Template Format:
keyword,affiliate_url,link_text,target,rel_attributes,css_class,max_insertions,status
best laptop,https://amazon.com/dp/B08N5WRWNW?tag=yourcode-20,Top Laptop Deal,_blank,nofollow sponsored,affiliate-tech,3,active
coffee maker,https://amazon.com/dp/B077JBQZPX?tag=yourcode-20,Best Coffee Maker,_blank,nofollow sponsored,affiliate-kitchen,2,active
CSV Column Descriptions:
| Column | Required | Description | Example Values |
|---|---|---|---|
| keyword | ✅ Yes | Text to replace | "best laptop", "coffee maker" |
| affiliate_url | ✅ Yes | Your affiliate link | "https://amazon.com/dp/...?tag=yourcode" |
| link_text | ❌ No | Custom display text | "Top Laptop Deal" (leave empty to use keyword) |
| target | ❌ No | Link target | "_blank" (new window) or "_self" (same window) |
| rel_attributes | ❌ No | SEO attributes | "nofollow sponsored" (recommended) |
| css_class | ❌ No | CSS styling class | "affiliate-tech", "my-affiliate-link" |
| max_insertions | ❌ No | Max links per post | 1, 2, 3, etc. (default: 3) |
| status | ❌ No | Link status | "active" or "inactive" (default: active) |
📤 Bulk Export
Export all your affiliate links to a CSV file for backup or migration.
How to Export:
- Go to Affiliate Links → Manage Links
- Click "Export CSV" button
- Save the downloaded file
Export Uses:
- Backup: Keep a copy of all your affiliate links
- Migration: Move links between WordPress sites
- Analysis: Analyze your affiliate link performance in Excel/Google Sheets
- Sharing: Share link data with team members
🔧 CSV Best Practices
✅ Do:
- Use the provided template for consistency
- Test with a small batch first (5-10 links)
- Keep URLs properly formatted with http:// or https://
- Use descriptive keywords (2-4 words work best)
- Include proper affiliate tracking codes
❌ Avoid:
- Duplicate keywords (will be skipped during import)
- Invalid URLs (missing http://, malformed)
- Very long keywords (over 255 characters)
- Special characters in keywords that might break HTML
🛠️ Troubleshooting Import Issues:
"Keyword already exists" errors:
- Check for duplicate keywords in your CSV
- Review existing links in the dashboard
- Consider using variations like "best laptops 2025" vs "best laptop"
"Invalid URL format" errors:
- Ensure all URLs start with http:// or https://
- Check for extra spaces or characters
- Validate affiliate links work in your browser
"Row skipped" messages:
- Missing required data (keyword or URL)
- Invalid data format
- Database insertion errors
📊 Import Results
After importing, you'll see a summary showing:
- ✅ Imported: Successfully added links
- ⚠️ Skipped: Links that couldn't be imported
- ❌ Errors: Specific issues with detailed descriptions
Review the error messages to fix any issues and re-import if needed.
SEO Best Practices
✅ Recommended Settings
- Use "nofollow sponsored" rel attributes
- Limit to 3-5 affiliate links per post
- Enable "whole words only" matching
- Exclude home page from insertion
- Use descriptive, natural link text
⚠️ Avoid Over-Optimization
- Don't stuff posts with too many affiliate links
- Ensure links are relevant to content
- Maintain good user experience
- Follow FTC disclosure guidelines
Database Structure
The plugin creates one table: wp_affiliate_links
Table Schema
CREATE TABLE wp_affiliate_links (
id mediumint(9) NOT NULL AUTO_INCREMENT,
keyword varchar(255) NOT NULL,
affiliate_url text NOT NULL,
link_text varchar(255) DEFAULT NULL,
target varchar(10) DEFAULT '_blank',
rel_attributes varchar(255) DEFAULT 'nofollow sponsored',
css_class varchar(255) DEFAULT NULL,
insertion_type varchar(20) DEFAULT 'automatic',
max_insertions int(5) DEFAULT 3,
position varchar(20) DEFAULT 'first',
created_at datetime DEFAULT CURRENT_TIMESTAMP,
updated_at datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
status varchar(20) DEFAULT 'active',
PRIMARY KEY (id)
);
Troubleshooting
Links Not Appearing
- Check if insertion is enabled in settings
- Verify keyword spelling in content
- Ensure link status is "Active"
- Check if max links per post limit is reached
Too Many Links
- Reduce "Max Links per Post" in settings
- Lower "Max Insertions" for individual links
- Use more specific keywords
Links in Wrong Places
- Enable "Whole Words Only" in settings
- Adjust keyword specificity
- Review case sensitivity settings
Performance Issues
- Limit number of active affiliate links
- Use specific keywords (avoid short, common words)
- Reduce max insertions per link
Hooks and Filters
Available Actions
// Before link insertion
do_action('ali_before_content_processing', $content, $post_id);
// After link insertion
do_action('ali_after_content_processing', $content, $post_id, $inserted_count);
// When link is saved
do_action('ali_link_saved', $link_id, $link_data);
// When link is deleted
do_action('ali_link_deleted', $link_id);
Available Filters
// Modify content before processing
$content = apply_filters('ali_pre_process_content', $content, $post_id);
// Modify link HTML output
$link_html = apply_filters('ali_link_html', $link_html, $link_data, $keyword);
// Modify insertion settings
$settings = apply_filters('ali_insertion_settings', $settings, $post_id);
Development
Extending the Plugin
Custom Link Processing
function custom_affiliate_link_html($link_html, $link_data, $keyword) {
// Add custom tracking parameters
$link_html = str_replace('href="', 'href="', $link_html);
return $link_html;
}
add_filter('ali_link_html', 'custom_affiliate_link_html', 10, 3);
Custom Content Filtering
function exclude_specific_posts($content, $post_id) {
// Skip certain post types
if (get_post_type($post_id) === 'custom_type') {
return $content; // Return unchanged
}
return $content;
}
add_filter('ali_pre_process_content', 'exclude_specific_posts', 10, 2);
Changelog
Version 1.0.0
- Initial release
- Automatic keyword-based affiliate link insertion
- Admin interface for managing links
- Global settings configuration
- SEO-friendly link attributes
- Performance optimization features
Support
For support, feature requests, or bug reports:
- Documentation: Check this README for common solutions
- WordPress Support: Visit WordPress.org plugin directory
- Custom Development: Contact for custom modifications
License
This plugin is licensed under the GPL v2 or later.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Credits
- Author: Dorien Vibecodes
- Built with: WordPress Plugin API
- Dependencies: None (standalone plugin)
- Compatibility: WordPress 5.0+ & PHP 7.4+
Ready to monetize your content? Install Affiliate Link Inserter today!