Problem modal search | WordPress.org

[ad_1]

ying

(@yingscarlett)

Hi there,

Try this PHP code:

Adding PHP: https://docs.generatepress.com/article/adding-php/

add_action( 'generate_inside_search_modal', 'custom_generate_do_search_fields' );
add_action('wp',function() {
	remove_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
});

/**
 * Modify our search fields to the modal.
 */
function custom_generate_do_search_fields() {
	?>
	<form role="search" method="get" class="search-modal-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
	
		
		<div class="search-modal-fields">
		<label for="gp-search-modal-input" class="screen-reader-text"><?php echo apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
			<input type="search" id="gp-search-modal-input" class="search-field" placeholder="<?php echo esc_attr( apply_filters( 'generate_search_placeholder', _x( 'Search &hellip;', 'placeholder', 'generatepress' ) ) ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
		
			<button aria-label="<?php echo esc_attr( apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) ); ?>"><?php echo generate_get_svg_icon( 'search' ); // phpcs:ignore -- Escaped in function. ?></button>
		</div>
		<?php do_action( 'generate_inside_search_modal_form' ); ?>
	</form>
	<?php
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer