Below, you’ll find a detailed guide on how to add the Advanced Woo Search Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Advanced Woo Search Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Advanced Woo Search Plugin and the shortcodes it provides:
"Advanced Woo Search is a powerful WordPress plugin designed to enhance the search functionality of your WooCommerce store. Quickly find products with this user-friendly tool."
- [aws_search_form]
- [wpb_aws_search_form]
Advanced Woo Search [aws_search_form] Shortcode
The Advanced Woo Search plugin shortcode, ‘aws_search_form’, generates a search form. It uses the AWS_Markup class to create the form based on the given arguments. The function ‘markup’ checks if the arguments are valid. If not, it initializes an empty array. It then creates a new instance of AWS_Markup with the arguments and returns the generated form.
Shortcode: [aws_search_form]
Examples and Usage
Basic example – A standard implementation of the ‘aws_search_form’ shortcode without any additional parameters.
[aws_search_form /]
Advanced examples
Using the shortcode with the ‘id’ parameter, which allows you to specify the ID of the search form you want to display. If a form with the given ID does not exist, the default form will be displayed.
[aws_search_form id=2 /]
Using the shortcode with the ‘title’ parameter. This allows you to specify the title of the search form you want to display. If a form with the given title does not exist, the default form will be displayed.
[aws_search_form title="My Custom Search Form" /]
Using the shortcode with multiple parameters. In this example, the ‘id’ and ‘title’ parameters are used together. The form will first try to load by ID, but if not found, it will try to load by title.
[aws_search_form id=2 title="My Custom Search Form" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [aws_search_form]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'aws_search_form', array( $this, 'markup' ) );
Shortcode PHP function:
function markup( $args = array() ) {
if ( ! $args || ! is_array( $args ) ) {
$args = array();
}
$markup = new AWS_Markup( $args );
return $markup->markup();
}
Code file location:
advanced-woo-search/advanced-woo-search/advanced-woo-search.php
Advanced Woo Search [wpb_aws_search_form] Shortcode
The Advanced Woo Search shortcode is used to render a custom search form. It accepts parameters such as ‘placeholder’, ‘extra_class’, and ‘element_id’ to customize the form. The PHP function ‘render_shortcode’ processes these parameters, creates a search form using ‘aws_get_search_form’ function, and wraps it in a div with the specified classes and id.
Shortcode: [wpb_aws_search_form]
Parameters
Here is a list of all possible wpb_aws_search_form shortcode parameters and attributes:
placeholder
– text displayed inside the search box when it’s emptyextra_class
– additional CSS class to style the search formelement_id
– unique identifier of the search form
Examples and Usage
Basic example – A simple implementation of the shortcode without any additional parameters. It will render a search form with the default placeholder, class, and id.
[wpb_aws_search_form /]
Advanced examples
Displaying the search form with a custom placeholder. In this example, the placeholder text in the search input field will be ‘Search Products’.
[wpb_aws_search_form placeholder="Search Products" /]
Applying a custom CSS class to the search form. This can be useful for applying specific styles to the search form. In this example, the CSS class ‘my-custom-class’ will be applied to the search form.
[wpb_aws_search_form extra_class="my-custom-class" /]
Assigning a unique id to the search form. This can be useful for targeting the search form with JavaScript or CSS. In this example, the id ‘my-custom-id’ will be assigned to the search form.
[wpb_aws_search_form element_id="my-custom-id" /]
Combining multiple parameters. This example demonstrates the usage of the shortcode with all available parameters. The search form will have the placeholder ‘Search Products’, the CSS class ‘my-custom-class’, and the id ‘my-custom-id’.
[wpb_aws_search_form placeholder="Search Products" extra_class="my-custom-class" element_id="my-custom-id" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wpb_aws_search_form]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wpb_aws_search_form', array( $this, 'render_shortcode' ) );
Shortcode PHP function:
function render_shortcode( $atts, $content, $tag ) {
$atts = (shortcode_atts(array(
'placeholder' => '',
'extra_class' => '',
'element_id' => ''
), $atts));
$placeholder = esc_html($atts['placeholder']);
$extra_class = esc_attr($atts['extra_class']);
$element_id = esc_attr($atts['element_id']);
$output = '';
if ( function_exists( 'aws_get_search_form' ) ) {
$args = $placeholder ? array( 'placeholder' => $placeholder ) : array();
$search_form = aws_get_search_form( false, $args );
$output = '<div class="aws-wpbakery-form ' . $extra_class . '" id="' . $element_id . '" >' . $search_form . '</div>';
}
return $output;
}
Code file location:
advanced-woo-search/advanced-woo-search/includes/modules/class-aws-wpbakery.php
Conclusion
Now that you’ve learned how to embed the Advanced Woo Search Plugin shortcodes, 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