Description
All Post Type Ajax Search adds a lightweight, secure search box that returns results in real time (AJAX). From the settings screen you choose exactly which content types (posts, pages, products and other custom post types) are included in the search. Each result shows a thumbnail (or a default image), the title and a link.
Main advantages:
- Fast front-end search with up to 5 results and a minimum of 3 characters.
- Full control from the admin: choose the post types that appear in the results.
- Smart filtering that hides technical types (attachments, revisions, orders, variations, etc.).
- Built following WordPress security best practices: nonces, sanitization and escaping.
- Simple procedural code, easy to customize for developers of any level.
- Translation ready (text domain: all-post-type-ajax-search).
Features
- Simple shortcode: [all-post-type-ajax-search].
- Admin settings: choose the enabled post types and set a default image (URL).
- Each result shows a thumbnail (or the default image), the title and a link.
- Results are spread across post types so posts or pages are not always shown first.
- Default limit of 5 results; searching starts at 3 characters.
- Performance: no_found_rows in queries, limited posts per query, and CSS/JS loaded only on pages that contain the shortcode.
- Security: nonces for AJAX and settings; capability checks (manage_options) in the admin.
Video
Additional Notes for Developers
- Stored options:
- aptas_search_post_types (array): enabled post types.
- aptas_default_image_url (string): default image URL.
- Nonces:
- AJAX: aptas_search_nonce
- Admin: aptas_settings_save (field name aptas_settings_nonce)
- Shortcode: [all-post-type-ajax-search]
- AJAX action: aptas_ajax_search (wp_ajax_aptas_ajax_search / wp_ajax_nopriv_aptas_ajax_search).
Installation
- Upload the
all-post-type-ajax-searchfolder to/wp-content/plugins/. - Activate the plugin through the Plugins menu in WordPress.
- Go to CP Ajax Search in the admin menu and select the post types to include.
- Add the shortcode
[all-post-type-ajax-search]wherever you want the search box.
FAQ
Which post types appear in the settings list?
Only relevant types: posts, pages, products and other custom post types that are public or have an admin UI. Technical types (attachment, revision, nav_menu_item, shop_order, product_variation, etc.) are hidden automatically.
Can I change the maximum number of results?
The limit is 5 results. It cannot be changed from the settings screen in this version.
How is the default image set?
In the plugin settings (CP Ajax Search) there is a field for the default image URL. Leave it empty to use the image included in the plugin.
Is it compatible with WooCommerce?
Yes. If the product post type is registered (WooCommerce), it appears in the list and can be included in the search.
Is it translation ready?
Yes. All strings use the internationalization functions and the text domain all-post-type-ajax-search.
Screenshots
Changelog
1.1.0
- Interface strings in English, ready for translation on translate.wordpress.org.
- Front-end JavaScript messages are now translatable.
- CSS and JS now load only on pages that contain the shortcode.
- Fixed: removed the request to a non-existent admin script.
- Readme: removed the mention of a filter that does not exist.
- Plugin header: added Requires at least, Requires PHP and License URI.
1.0.0
- Initial release.
- Shortcode [all-post-type-ajax-search].
- Settings screen: post types selection and default image URL.
- Real-time AJAX search with a result limit and distribution by post type.
- Secure implementation (nonces, sanitization, escaping) and optimized queries (no_found_rows).






