33. Filter Reference | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

33. Filter Reference

Developer Guide

All WordPress filters that SEO Forge hooks into, plus custom filters provided by SEO Forge for developer extensibility.

WordPress Filters Used by SEO Forge

FilterClassMethodPriorityDescription
robots_txtSEOFORGE_Robots_Txtcustom_robots_txt10Custom robots.txt content
sanitize_file_nameSEOFORGE_Image_Seoclean_filename10Clean uploaded image filenames
admin_body_classSEOFORGE_Coreadd_body_class10Adds sf-admin class to admin body
document_title_partsSEOFORGE_AB_Testing(closure)10Swaps title for A/B variant B
attachment_fields_to_editSEOFORGE_Image_Seoalt_text_reminder10Missing alt text warning

SEO Forge Custom Filters

FilterParametersDescription
seoforge_template_variables$vars (array)Add custom template variables to the meta template system
seoforge_resolve_template$output, $post_idResolve custom variables during meta template rendering

Using Filters in Your Code

php
// Modify the title after SEO Forge processing
add_filter( 'document_title_parts', function ( $title_parts ) {
    $title_parts['title'] .= ' (' . date( 'Y' ) . ')';
    return $title_parts;
}, 20 );

// Modify robots.txt after SEO Forge
add_filter( 'robots_txt', function ( $output, $public ) {
    $output .= "nUser-agent: GPTBotnDisallow: /n";
    return $output;
}, 20, 2 );

// Prevent filename cleanup for specific file types
add_filter( 'sanitize_file_name', function ( $filename ) {
    // Preserve original filenames for PDF uploads
    if ( pathinfo( $filename, PATHINFO_EXTENSION ) === 'pdf' ) {
        return $filename;
    }
    return $filename;
}, 5 ); // Priority 5 runs before SEO Forge's 10

// Add custom variables to the meta template system
add_filter( 'seoforge_template_variables', function ( $vars ) {
    $vars['{{reading_time}}'] = 'Estimated reading time';
    return $vars;
} );

add_filter( 'seoforge_resolve_template', function ( $output, $post_id ) {
    $content = get_post_field( 'post_content', $post_id );
    $word_count = str_word_count( wp_strip_all_tags( $content ) );
    $minutes = max( 1, ceil( $word_count / 200 ) );
    return str_replace( '{{reading_time}}', "{$minutes} min read", $output );
}, 10, 2 );

Forge AI Assistant Online

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

Just now
Powered by Forge AI · Browse docs