SearchWP Modal Search Form Shortcode

Below, you’ll find a detailed guide on how to add the SearchWP Modal Search Form 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 SearchWP Modal Search Form Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the SearchWP Modal Search Form Plugin and the shortcodes it provides:

Plugin Icon
SearchWP Modal Search Form

"SearchWP Modal Search Form is a powerful plugin that enhances your WordPress search functionality. It provides a user-friendly modal form, ensuring a seamless search experience."

★★★★★ (6) Active Installs: 5000+ Tested with: 6.0.6 PHP Version: 5.6
Included Shortcodes:
  • [searchwp_modal_search_form]

SearchWP Modal Search Form [searchwp_modal_search_form] Shortcode

The SearchWP Modal Search Form shortcode is a PHP function that generates a search form. It uses customizable attributes like engine, template, text, type, and class. This shortcode enables the display of a search form in a modal window. You can specify the search engine, design template, display text, form type, and additional CSS classes. It returns the search form output.

Shortcode: [searchwp_modal_search_form]

Parameters

Here is a list of all possible searchwp_modal_search_form shortcode parameters and attributes:

  • engine – Defines which SearchWP engine to use
  • template – Specifies the template for the search form
  • text – Sets the text of the search button
  • type – Determines the type of trigger (link or button)
  • class – Allows adding custom CSS classes

Examples and Usage

Basic example – A simple usage of the searchwp_modal_search_form shortcode with default parameters.

[searchwp_modal_search_form /]

Advanced examples

Using the shortcode to change the search engine, template, and text. Here, we are specifying the ‘engine’ parameter as ‘advanced’, the ‘template’ as ‘Custom’, and the ‘text’ as ‘Find’.

[searchwp_modal_search_form engine="advanced" template="Custom" text="Find" /]

Another advanced example is to change the type and class of the search form. Here, we are specifying the ‘type’ parameter as ‘button’ and the ‘class’ as ‘custom-class’.

[searchwp_modal_search_form type="button" class="custom-class" /]

Finally, an example where we use all the parameters. We are setting the ‘engine’ as ‘advanced’, the ‘template’ as ‘Custom’, the ‘text’ as ‘Find’, the ‘type’ as ‘button’, and the ‘class’ as ‘custom-class’.

[searchwp_modal_search_form engine="advanced" template="Custom" text="Find" type="button" class="custom-class" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [searchwp_modal_search_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'searchwp_modal_search_form', array( $this, 'shortcode' ) );

Shortcode PHP function:

function shortcode( $atts ) {
		$args = shortcode_atts( array(
			'engine'   => 'default',
			'template' => 'Default',
			'text'     => __( 'Search', 'searchwp-modal-search-form' ),
			'type'     => 'link',
			'class'    => array(),
		), $atts );

		$args['echo'] = true;

		ob_start();

		searchwp_modal_form_trigger( $args );

		return ob_get_clean();
	}

Code file location:

searchwp-modal-search-form/searchwp-modal-search-form/includes/Shortcode.php

Conclusion

Now that you’ve learned how to embed the SearchWP Modal Search Form 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *