Keyword Suggestions

Keyword suggestion and autocomplete hooks

All suggestions

asp/suggestions/keywords

Hook to the final suggested keywords from all selected sources.

add_filter('asp/suggestions/keywords', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $keywords, $phrase ) {
	return $keywords;
}

Parameters

  • $keywords (array) - the array of the suggersted keywords

  • $phrase (string) - the search phrase

Post Title Suggestions

asp/suggestions/post_type/query

add_filter('asp/suggestions/post_type/query', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $query, $phrase) {
	return $query;
}

Parameters

  • $query (string) - the final query before execution

  • $phrase (string) - the search phrase

asp/suggestions/post_type/results

add_filter('asp/suggestions/post_type/results', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $posts, $phrase ) {
	return $posts;
}

Parameters

  • $keywords (array) - the array of the suggersted keywords

  • $posts (array[object]) - Array of Posts (ID and post_title)

WARNING! The $post argument in this hook is not an array of WP_Post objects! The items only have the ID and title columns ($post->ID, $post->post_title)

Taxonomy Term Suggestions

asp/suggestions/taxonomy/results

add_filter('asp/suggestions/taxonomy/results', 'asp_change_keyword_suggestions', 10,4);
function asp_change_keyword_suggestions( $query, $phrase, $taxonomy, $args ) {
	return $query;
}

Parameters

  • $query (string) - the final query before execution

  • $phrase (string) - the search phrase

  • $taxonomy (string) - the taxonomy name

  • $args (array) - the arguments

Search Statistics Suggestions

asp/suggestions/statistics/query

add_filter('asp/suggestions/statistics/query', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $query, $phrase) {
	return $query;
}

Parameters

  • $query (string) - the final query before execution

  • $phrase (string) - the search phrase

asp/suggestions/statistics/results

add_filter('asp/suggestions/statistics/results', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $keywords, $phrase ) {
	return $posts;
}

Parameters

  • $keywords (array) - the array of the suggersted keywords

  • $posts (array) - Array of suggested keywords

Google Suggestions

asp/suggestions/google/url

add_filter('asp/suggestions/google/url', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $url, $args) {
	return $url;
}

Parameters

  • $url (string) - the google suggestions URL

  • $args (array) - the array of arguments for the suggestion

asp/suggestions/google/results

add_filter('asp/suggestions/google/results', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $keywords, $phrase ) {
	return $keywords;
}

Parameters

  • $keywords (array) - the array of the suggersted keywords

  • $phrase (string) - the search phrase

Google Places API Suggestions

asp/suggestions/google/url

add_filter('asp/suggestions/google_places/url', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $url, $args) {
	return $url;
}

Parameters

  • $url (string) - the google suggestions URL

  • $args (array) - the array of arguments for the suggestion

asp/suggestions/google/results

add_filter('asp/suggestions/google_places/results', 'asp_change_keyword_suggestions', 10, 2);
function asp_change_keyword_suggestions( $keywords, $phrase ) {
	return $keywords;
}

Parameters

  • $keywords (array) - the array of the suggersted keywords

  • $phrase (string) - the search phrase

Last updated

Copyright Ernest Marcinko