SEO Forge provides two internal linking mechanisms: link suggestions and auto-links on publish. PRO feature.
Link Suggestion Algorithm
SEOFORGE_Internal_Links::suggest( $post_id ) extracts keywords from the post, queries for matching published posts, then scores each candidate by relevance.
Relevance scoring:
- +10 points for each keyword match in candidate post’s title
- +
(similar_text percentage / 5)bonus for overall title similarity
php
// Get link suggestions for a post
$links = SEOFORGE_Internal_Links::instance()->suggest( $post_id, 10 );
// Use suggestions in a custom metabox
add_action( 'add_meta_boxes', function () {
add_meta_box( 'my_link_suggestions', 'Link Suggestions', function ( $post ) {
if ( ! class_exists( 'SEOFORGE_Internal_Links' ) ) {
return;
}
$suggestions = SEOFORGE_Internal_Links::instance()->suggest( $post->ID, 5 );
echo '<ul>';
foreach ( $suggestions as $link ) {
echo '<li><a href="' . esc_url( $link['url'] ) . '">'
. esc_html( $link['title'] ) . '</a> (relevance: ' . intval( $link['relevance'] ) . ')</li>';
}
echo '</ul>';
}, 'post', 'side' );
} );Auto-Links on Publish
SEOFORGE_Auto_Links runs on transition_post_status when a post transitions to publish for the first time.
Scoring for related posts:
| Signal | Points |
|---|---|
| Shared category | +3 |
| Shared tag | +2 |
| Title keyword match | +5 |
| Content keyword mention | +1 |
tags and heading tags. Inserts marker before each auto-link.
php
$auto_links = SEOFORGE_Auto_Links::instance();
$enabled = $auto_links->is_enabled();
$max = $auto_links->get_max_links();
$related = $auto_links->find_related_posts( $post_id, 5 );
$auto_links->insert_links_in_content( $post_id, $related, 3 );Configuration
php
update_option( 'seoforge_auto_links_enabled', true );
update_option( 'seoforge_auto_links_max', 5 ); // min 1, max 10—