All WordPress filters that SEO Forge hooks into, plus custom filters provided by SEO Forge for developer extensibility.
WordPress Filters Used by SEO Forge
| Filter | Class | Method | Priority | Description |
|---|---|---|---|---|
robots_txt | SEOFORGE_Robots_Txt | custom_robots_txt | 10 | Custom robots.txt content |
sanitize_file_name | SEOFORGE_Image_Seo | clean_filename | 10 | Clean uploaded image filenames |
admin_body_class | SEOFORGE_Core | add_body_class | 10 | Adds sf-admin class to admin body |
document_title_parts | SEOFORGE_AB_Testing | (closure) | 10 | Swaps title for A/B variant B |
attachment_fields_to_edit | SEOFORGE_Image_Seo | alt_text_reminder | 10 | Missing alt text warning |
SEO Forge Custom Filters
| Filter | Parameters | Description |
|---|---|---|
seoforge_template_variables | $vars (array) | Add custom template variables to the meta template system |
seoforge_resolve_template | $output, $post_id | Resolve 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 );—