Support Log in

33. Filter Reference

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

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

WordPress Filters Used by Rank Forge

FilterClassMethodPriorityDescription
robots_txtRANKFORGE_Robots_Txtcustom_robots_txt10Custom robots.txt content
sanitize_file_nameRANKFORGE_Image_Seoclean_filename10Clean uploaded image filenames
admin_body_classRANKFORGE_Coreadd_body_class10Adds sf-admin class to admin body
document_title_partsRANKFORGE_AB_Testing(closure)10Swaps title for A/B variant B
attachment_fields_to_editRANKFORGE_Image_Seoalt_text_reminder10Missing alt text warning

Rank Forge Custom Filters

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

Using Filters in Your Code

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

// Modify robots.txt after Rank 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 Rank Forge's 10

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

add_filter( 'rankforge_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 Rank Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs