Below, you’ll find a detailed guide on how to add the YITH WooCommerce Ajax Search Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the YITH WooCommerce Ajax Search Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the YITH WooCommerce Ajax Search Plugin and the shortcodes it provides:
"YITH WooCommerce Ajax Search is a powerful plugin that enhances your online store's search functionality. It enables real-time product search, improving user experience and navigation."
- [yith_woocommerce_ajax_search]
YITH WooCommerce Ajax Search [yith_woocommerce_ajax_search] Shortcode
The yith_woocommerce_ajax_search shortcode is a vital part of the YITH WooCommerce AJAX Search plugin. It enables AJAX search functionality on your WooCommerce site. This shortcode initiates the AJAX search feature, capturing the search parameters and returning the results without page reloads. The code removes the ‘template’ argument for WooCommerce 3.6.0 and beyond, ensuring compatibility.
Shortcode: [yith_woocommerce_ajax_search]
Examples and Usage
Basic example – Showcases the use of the yith_woocommerce_ajax_search shortcode without any additional parameters.
[yith_woocommerce_ajax_search]
PHP Function Code
In case you have difficulties debugging what causing issues with [yith_woocommerce_ajax_search]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'yith_woocommerce_ajax_search', array( $this, 'add_woo_ajax_search_shortcode' ) );
Shortcode PHP function:
function add_woo_ajax_search_shortcode( $args = array() ) {
$args = shortcode_atts( array(), $args );
// for WC 3.6.0.
unset( $args['template'] );
ob_start();
$wc_get_template = function_exists( 'wc_get_template' ) ? 'wc_get_template' : 'woocommerce_get_template';
$wc_get_template( 'yith-woocommerce-ajax-search.php', $args, '', YITH_WCAS_DIR . 'templates/' );
return ob_get_clean();
}
Code file location:
yith-woocommerce-ajax-search/yith-woocommerce-ajax-search/includes/class.yith-wcas.php
Conclusion
Now that you’ve learned how to embed the YITH WooCommerce Ajax Search Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply