Site logo

[Resolved] Change the search field requests to the database from GET to POST

Home Forums Support [Resolved] Change the search field requests to the database from GET to POST

Home Forums Support Change the search field requests to the database from GET to POST

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2510116
    Domenico

    Hello.
    I would like to change the method in which requests to the database are handled when doing a search from the search field. Generatepress manages requests using the GET method and every time a search is performed a page is generated with this url: nomesito.it/?s=term-searched
    Also you create a page with searched term h1

    This for me is a problem because it is exposed to attacks by negative seo.

    Can you help me change the method of handling database requests from the lookup field from GET to POST?
    Furthermore, I would like the page with the result to always have the same url: sitename/page-result.

    I would like to be able to insert a php code via WP Codebox which I have already installed as a plugin.
    Or with Advanced Script or whatever.

    Thanks a lot for your help.

    #2510450
    Ying
    Staff
    Customer Support

    Hi Domenico,

    Try this PHP filter for GP’s navigation search:

    add_filter('generate_navigation_search_output', function() {
    			printf(
    				'<form method="post" class="search-form navigation-search" action="%1$s">
    					<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
    				</form>',
    				esc_url( home_url( '/' ) ),
    				esc_attr( get_search_query() ),
    				esc_attr_x( 'Search', 'label', 'generatepress' )
    			);
    });
    #2510499
    Domenico

    Works great!
    Thank you so much Ying!

    #2511340
    Ying
    Staff
    Customer Support

    No Problem, glad to help 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.