Hey folks – I noticed it wasn’t working here anymore. Sorry ’bout that!
Here’s what I had to do to get it back on-line:
Firstly, I reverted back to the default WP search using the Search widget in the sidebar. I was previously using a plug-in and wasn’t sure if it was playing a part in my problems. (I had recently switched hosting providers and made changes to my site and home URLS)
After adding the widget, it threw the search box in a strange place on the sidebar. Had to get that sorted. Used the following CSS in my style.css file:
Now it’s right up at the top. Good
Under the hood – search.php and searchform.php
1. I switched themes to twenty seventeen and noticed it worked ok so narrowed it down to something in my theme files (I’m using Thoughts)
2. Turned on debugging in wp-config.php by setting define('WP_DEBUG','true');
3. Noticed I was getting a parse error in search.php. Appears there was an ampersand before the keyword new. Removed it and saved file. Here’s what the line looks like now:
<h2 class="spage-title">Search Result for <?php /* Search Count */ $allsearch = new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->p
ost_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2>
4. Switched back to main theme. Tested and all working Ok!
Monday is off to a good start!