Using the ‘seo_booster_question_phrases’ filter

SEO Booster Pro includes a filter hook named seo_booster_question_phrases, allowing developers to customize the list of question phrases used in reports. This guide explains how to utilize this filter and provides the default values for the question phrases.

Purpose of the filter

The seo_booster_question_phrases filter enables modification of the default set of question phrases that SEO Booster Pro uses to identify and analyze search queries. By customizing this list, you can tailor the plugin’s reporting to better align with specific languages or query patterns relevant to your target audience.

Default question phrases

By default, SEO Booster Pro defines a set of question phrases across multiple languages, including English, Danish, Swedish, and Norwegian. Here are the default phrases:

  • English:
    'how to ', 'what is ', 'why ', 'who ', 'where ', 'when ', 'can ', 'does ', 'do ', 'is ', 'are ', 'should ', 'could ', 'would '
  • Danish:
    'hvordan ', 'hvad er ', 'hvorfor ', 'hvem ', 'hvor ', 'hvornår ', 'kan ', 'gør ', 'er ', 'skal ', 'kunne ', 'ville '
  • Swedish:
    'hur ', 'vad är ', 'varför ', 'vem ', 'var ', 'när ', 'kan ', 'gör ', 'är ', 'ska ', 'kunde ', 'skulle '
  • Norwegian:
    'hvordan ', 'hva er ', 'hvorfor ', 'hvem ', 'hvor ', 'når ', 'kan ', 'gjør ', 'er ', 'skal ', 'kunne ', 'ville '

Applying the filter

To customize the question phrases, you can use the add_filter function in your theme’s functions.php file or within a custom plugin. Here’s how to add or modify question phrases:

function custom_seo_booster_question_phrases( $phrases ) {
    // Add custom phrases
    $phrases[] = 'comment '; // French for 'how'
    $phrases[] = 'qué es ';  // Spanish for 'what is'

    // Remove specific default phrases if necessary
    $phrases = array_diff( $phrases, array( 'who ', 'where ' ) );

    // Ensure phrases are unique and reindex the array
    $phrases = array_values( array_unique( $phrases ) );

    return $phrases;
}
add_filter( 'seo_booster_question_phrases', 'custom_seo_booster_question_phrases' );

In this example:

  • We add new phrases for French and Spanish.
  • We remove the English phrases 'who ' and 'where ' from the default list.
  • We ensure the array contains unique values and is properly indexed.

Supporting German language questions

function add_german_question_phrases( $phrases ) {
    $german_phrases = [
        'wie ', 'was ist ', 'warum ', 'wer ', 'wo ', 'wann ',
        'kann ', 'sollte ', 'dürfte ', 'wird ', 'ist ', 'sind '
    ];

    $phrases = array_merge( $phrases, $german_phrases );
    return array_values( array_unique( $phrases ) );
}
add_filter( 'seo_booster_question_phrases', 'add_german_question_phrases' );

This example merges the German question phrases with the default list (English, Danish, Swedish, Norwegian). If you prefer to only analyze German questions, you can skip the merge and return just the German array:

function only_german_question_phrases( $phrases ) {
    return [
        'wie ', 'was ist ', 'warum ', 'wer ', 'wo ', 'wann ',
        'kann ', 'sollte ', 'dürfte ', 'wird ', 'ist ', 'sind '
    ];
}
add_filter( 'seo_booster_question_phrases', 'only_german_question_phrases' );

By applying this filter, SEO Booster Pro will use the customized list of question phrases in its reports, allowing for more tailored and relevant analysis based on your specified criteria.