SM - Auto Internal Linker
Automatically links predefined keywords/phrases in news articles to related posts within the site.
by Martin Nestorov · github.com/mnestorov/smarty-auto-internal-linker · 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/mnestorov/smarty-auto-internal-linker/archive/refs/heads/main.zipReadme
SM - Auto Internal Linker
- Developed by: Martin Nestorov
– Explore more at nestorov.dev - Plugin URI: https://github.com/mnestorov/smarty-auto-internal-linker
Overview
SM – Auto Internal Linker is a lightweight WordPress plugin that automatically turns the first occurrences of predefined keywords or phrases inside your posts into bold, SEO-friendly internal links. Originally built for high-throughput news sites, it now ships with Polylang-aware language scoping, so every keyword can link only inside the language you choose.
Description
The plugin watches every post/page on render, finds matching keywords in the body (never in headings, quotes, or existing anchors) and injects an <a> element that :
- points to the URL you defined,
- inherits the exact capitalisation the reader sees (e.g. NFT, nft or Nft),
- carries an optional nofollow attribute,
- is styled with the class
.smarty-aul-link(bold by default).
The admin screen lets editors manage keywords, per-keyword link limits and language with a friendly UI. An hourly WP-Cron task back-fills links into older posts so your archive stays fresh as new keywords arrive.
Features
| Category | What you get |
|---|---|
| Smart linking | Case-insensitive matching with word boundaries, preserves original casing in output. |
| Per-keyword cap | Each keyword obeys its own max-links-per-post value (1 – 3). |
| Language scope | New Language selector (Any / bg / en …). Keywords link only in the chosen Polylang language. |
| Scope control | Skips headings <h1-h6>, blockquotes, existing <a> tags. |
| Admin UI | Add / edit / delete keywords, set dofollow / nofollow, max links, all from WP Dashboard. |
| Cron for old posts | Hourly routine updates 20 older posts (older than a week) with fresh links. |
| Bold by default | Injected links get font-weight:bold; via a tiny inline stylesheet (easily override). |
| Performance | MySQL table + 24 h transient cache; zero queries on most page loads. |
| No classes, pure functions | 100 % procedural PHP with smarty_aul_ prefix and function_exists guards. |
| I18n-ready | Text domain smarty-auto-internal-linker; ready for translation files in /languages. |
Installation
-
Download the plugin
grabsmarty-auto-internal-linker.phpfrom the repo’s latest release. -
Upload & activate
Plugins → Add New → Upload Plugin → choose the file → Install → Activate. -
(First-run)
On activation the plugin will:- create the table
{$wpdb->prefix}smarty_aul_dictionary_keywords, - schedule the hourly WP-Cron event.
- create the table
-
Done.
A new top-level menu “Auto Links” appears in the admin sidebar.
Usage
-
Add a keyword
Auto Links → Add Keyword → fill in the phrase, target URL, choose max links/post and rel. -
Edit / delete
Click Edit next to an entry, update the fields and click Update Keyword.
Or click Delete to remove it entirely. -
Styling
Links are bold by default via.smarty-aul-link. Override in your theme:.smarty-aul-link{font-weight:600;color:#1e90ff;text-decoration:none;} -
Testing View any single post containing the phrase – on the first render you’ll see the new link.
Frequently Asked Questions
Q: The plugin isn’t linking anything. What’s wrong?
A: Make sure the keyword exists exactly (case doesn’t matter but spaces do). Ensure you haven’t hit the global (3) or per-keyword cap.
Q: Can I link inside custom post types?
A: Change the early guard in smarty_aul_filter_content() to add your CPT condition.
Q: How do I disable the bold style?
A: Either dequeue the inline style:
add_action( 'wp_enqueue_scripts', function(){
wp_dequeue_style( 'smarty-aul-inline' );
}, 20 );
or override .smarty-aul-link{font-weight:normal;} in your theme CSS.
Q: Will it slow my site down?
A: No – the dictionary is cached for 24 h and the DOM manipulation runs only on single post views.
Q: How can I import 500 keywords at once?
A: Insert rows directly into wp_smarty_aul_dictionary_keywords (or use WP-CLI) and then delete_transient( 'smarty_aul_dictionary_cache' );.
Translation
This plugin is translation-ready. Add translations to the languages directory.
Changelog
For a detailed list of changes and updates made to this project, please refer to our Changelog.
License
This project is released under the GPL-2.0+ License.