Skip to Content

autocomplete_search()

Run an AJAX autocomplete search of all published posts types (including menu items and authors too).

PHP July 23, 2018

Usage

PHP
nebula()->autocomplete_search()

Parameters

term
(Required) (String) Search keyword or phrase
Default: None

Parameter Notes

term is passed in an AJAX data object.

Request or provide clarification »

Examples

Globally exclude attachments and menus from autocomplete search results.

PHP
add_filter('nebula_autocomplete_ignore_types', function($ignore_post_types){
    $ignore_post_types[] = 'attachment';
    $ignore_post_types[] = 'menu';
    return $ignore_post_types;
});

Globally ignore individual posts from autocomplete search results.

PHP
add_filter('nebula_autocomplete_ignore_ids', function($ignore_post_ids){
    $ignore_post_ids[] = 123;
    $ignore_post_ids[] = 456;
    return $ignore_post_ids;
});

Additional Notes

This functions searches post data as well as custom field data.

Post types can specifically be excluded from autocomplete searches with the filter nebula_autocomplete_ignore_types.
Individual posts can specifically be excluded from autocomplete searches with the filter nebula_autocomplete_ignore_ids.
See examples.

Source File

This function was not found in /libs/Functions.php. Please report this error.

No Hooks

This function does not have any filters or actions available. Request one?

Override

This function can not be short-circuited with an override filter. Request one?