Custom WordPress Theme – Search not working on posts
Your form doesn’t have an action, so it submits to whatever the current URL is. You can point it to home_url() so it will submit there regardless of what page you search from. <form method=”get” action=”<?php echo esc_url( home_url() ); ?>”>