Search in Place Shortcode

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

Before starting, here is an overview of the Search in Place Plugin and the shortcodes it provides:

Plugin Icon
Search in Place

"Search in Place is a powerful WordPress plugin designed to enhance your website's search functionality. It delivers real-time search results, improving user experience and site navigation."

★★★★☆ (51) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [search-in-place-form]

Search in Place [search-in-place-form] Shortcode

The Search-in-Place shortcode is a powerful tool that enhances the search functionality on your WordPress site. It dynamically adjusts the search results as the user types their query. This shortcode allows customization such as enabling search within the current page, disabling the enter key, excluding hidden terms, and adding a placeholder. It also provides an option to disable the pop-up search results and to hide the search button. It wraps the search form within a div container and applies necessary data attributes based on the provided attributes. The shortcode is highly flexible and can be tailored to meet specific needs, improving the user experience on your site.

Shortcode: [search-in-place-form]


Here is a list of all possible search-in-place-form shortcode parameters and attributes:

  • in_current_page – Enables search only on the current page.
  • disable_enter_key – Disables the Enter key in the search form.
  • exclude_hidden_terms – Excludes hidden terms from the search results.
  • placeholder – Sets a placeholder text in the search box.
  • no_popup – Disables the search result pop-up.
  • display_button – Controls the display of the search button.

Examples and Usage

Basic example – Display a search form with the default settings.

[search-in-place-form /]

Advanced examples

Display a search form that only searches the current page, and disables the enter key.

[search-in-place-form in_current_page=1 disable_enter_key=1 /]

Display a search form that excludes hidden terms and uses a custom placeholder text.

[search-in-place-form exclude_hidden_terms=1 placeholder="Enter your search term here" /]

Display a search form that doesn’t show a popup, and doesn’t display the search button.

[search-in-place-form no_popup=1 display_button=0 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [search-in-place-form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'search-in-place-form', array( $codepeople_search_in_place_obj, 'get_search_form' ) );

Shortcode PHP function:

                    function get_search_form( $atts = array() ) {
		$args = shortcode_atts(
			array( 'in_current_page' => 0 ),

		$in_current_page = @intval( $args['in_current_page'] );

		$search = get_search_form( false );
		$search = str_replace(
			'name="s" data-search-in-place="1"' . ( $in_current_page ? ' data-search-in-page="1"' : '' ),

		if ( ! $in_current_page && isset( $atts['disable_enter_key'] ) && @intval( $atts['disable_enter_key'] ) ) {
			$search = str_replace( 'name="s"', 'name="s" data-disable-enter-key="1"', $search );

		if ( isset( $atts['exclude_hidden_terms'] ) && @intval( $atts['exclude_hidden_terms'] ) ) {
			$search = str_replace( 'name="s"', 'name="s" data-exclude-hidden="1"', $search );

		if ( isset( $atts['placeholder'] ) ) {
			if ( preg_match( '/placeholder="[^"]*"/i', $search ) ) {
				$search = preg_replace( '/placeholder="[^"]*"/i', 'placeholder="' . esc_attr__( $atts['placeholder'], 'search-in-place' ) . '"', $search );
			} else {
				$search = preg_replace( '/name="s"/i', 'name="s" placeholder="' . esc_attr__( $atts['placeholder'], 'search-in-place' ) . '"', $search );

		if ( isset( $atts['no_popup'] ) && @intval( $atts['no_popup'] ) ) {
			$search = str_replace( 'name="s"', 'name="s" data-no-popup="1"', $search );

		$search = preg_replace( '/<\/form>/i', '<input type="hidden" name="search_in_place_form" value="1"></form>', $search );
		$search = '<div class="search-in-place-box-container ' . ( isset( $atts['display_button'] ) && @intval( $atts['display_button'] ) ? '' : 'hide-search-button' ) . ' ">' . apply_filters( 'search-in-page-form', $search ) . '</div>';
		return str_replace( array( 're-ajax-search' ), '', $search );

Code file location:



Now that you’ve learned how to embed the Search in Place 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

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