Search only working on front page (index) , not working on other pages

Question

I’m currently building a custom WordPress template and I’ve run into a problem with the search box.

When I use the searchbox from the homepage, it works as intended. It also works as long as Permalinks are set to default. (url.com/?page_id=1)

However, when I use the searchbox from another page when using pretty permalinks, the URL looks something like this:
http://url.com/pretty-page-title/?s=query
and a 404 page appears.

My search box code looks like this

<form id="search-query">
<div class="search-box">
<form role="search" method="get" id="searchform" class="searchform" action="/index.php">
<div>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
</div>
</form>
</div>
</form>

Here’s the site’s URL if anyone’s want to take a look: http://hermodsgymnasiet-develop.kaigan.modxcloud.com/

Any help is very appreciated!

0
, , , , mizuki 3 years 2020-04-03T16:53:20-05:00 0 Answers 92 views 0

Leave an answer

Browse
Browse