Support Log in

17. Extending the Sitemap

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

Customize sitemap output for special requirements such as adding custom post types, excluding specific URLs, or modifying the ping behavior.

Adding Custom Post Types to the Sitemap

php
// Programmatically add a custom post type to the sitemap
$settings = get_option( 'rankforge_sitemap_settings', [] );
$enabled  = $settings['enabled_types'] ?? [ 'post', 'page' ];

if ( ! in_array( 'portfolio', $enabled, true ) ) {
    $enabled[] = 'portfolio';
    $settings['enabled_types'] = $enabled;
    update_option( 'rankforge_sitemap_settings', $settings );

    // Flush cache so the new type appears immediately
    RANKFORGE_Sitemap::instance()->invalidate_cache();
}

Excluding Specific URLs from the Sitemap

Since Rank Forge uses the _rankforge_noindex meta to control sitemap inclusion, you can programmatically exclude posts:

php
// Exclude all posts in a specific category from the sitemap
$posts = get_posts( [
    'category_name'  => 'internal-only',
    'posts_per_page' => -1,
    'fields'         => 'ids',
] );

foreach ( $posts as $pid ) {
    update_post_meta( $pid, '_rankforge_noindex', '1' );
}

RANKFORGE_Sitemap::instance()->invalidate_cache();

Disabling Google Ping on Publish

php
add_action( 'init', function () {
    if ( ! class_exists( 'RANKFORGE_Sitemap' ) ) {
        return;
    }
    remove_action( 'transition_post_status', [ RANKFORGE_Sitemap::instance(), 'maybe_ping_google' ] );
}, 20 );

Increasing Max URLs Per Sitemap

php
$settings = get_option( 'rankforge_sitemap_settings', [] );
$settings['max_urls'] = 5000; // Increase from default 1000
update_option( 'rankforge_sitemap_settings', $settings );
RANKFORGE_Sitemap::instance()->invalidate_cache();

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