Support Log in

21. Internal Links

Developer Guide
Prefer video? Watch the Rank Forge tutorials 9 short guides covering every feature Watch

Rank Forge provides two internal linking mechanisms: link suggestions and auto-links on publish. PRO feature.

Link Suggestion Algorithm

RANKFORGE_Internal_Links::suggest( $post_id, $limit = 10 ) works in two steps. When AI is configured on the site (RANKFORGE_AI_Client::is_configured()) and the license includes internal_links, it first sends the post title, the first 2000 characters of the post text and up to 30 other published posts and pages to the AI service, and returns what comes back. $limit does not apply to that answer, and the service is asked to describe each link with post_id, anchor_text and context, not with the fields used below. If the AI client reports that no account is connected, that the connection is no longer valid or that credits are used up (not_connected, credits_connection_invalid, credits_account_exhausted, credits_exhausted), suggest() returns that WP_Error.

In every other case, and whenever AI is not configured, it falls back to keyword matching: it extracts keywords from the post, queries for matching published posts, then scores each candidate by relevance. Rank Forge has no screen that lists these suggestions; they are available through this method and through the REST route GET /rankforge/v1/links/suggest/{post_id}.

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 = RANKFORGE_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( 'RANKFORGE_Internal_Links' ) ) {
            return;
        }
        $suggestions = RANKFORGE_Internal_Links::instance()->suggest( $post->ID, 5 );
        if ( is_wp_error( $suggestions ) ) {
            return;
        }
        echo '<ul>';
        foreach ( $suggestions as $link ) {
            // Skip entries without the fields of the keyword method (an AI answer is shaped differently)
            if ( ! isset( $link['url'], $link['title'], $link['relevance'] ) ) {
                continue;
            }
            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

RANKFORGE_Auto_Links runs its auto_link_on_publish callback on transition_post_status (priority 10) when a post or page moves to publish from any other status, such as draft or scheduled. Saving a post that is already published does not run it. The callback is hooked only when the site’s license allows auto_links, and it does nothing until rankforge_auto_links_enabled is on (see Configuration below). Scoring for related posts:
SignalPoints
Shared category+3
Shared tag+2
Title keyword match+5
Content keyword mention+1
Safety rules: Skips text inside <a> tags and heading tags. Inserts <!-- rankforge-autolink --> marker before each auto-link.
php
$auto_links = RANKFORGE_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( 'rankforge_auto_links_enabled', true );
update_option( 'rankforge_auto_links_max', 5 ); // min 1, max 10

—

Forge AI Assistant Online

Hi! I'm the Rank Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs