0

How can I display the search results on the same page where I have put search form?

1 Answer 1

0

Can you explain how did you put the search form? Are you working in code or with any page builders?

Assuming you are using code, best case is to use Javascript / Ajax to search in the same page.

Other options include submitting the search form and reloading the page with data. You can add form submit action like this to submit your search form to the same page.

 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
    // your search input here
 </form>

Then in the same page, you catch the form submission like this and show the results.

if ($_SERVER['REQUEST_METHOD'] === 'POST'){
    enter code here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.