WordPress MU search

29 01 2007

I’ve found that quite a few themes from the WordPress themes browser don’t permit searching properly when installed in WordPress MU.

I have WPMU installed with a home-page and blogs in subdirectories. When searching in a user’s blog, you are taken to the home-page and no results are displayed at all.

What I’ve managed to do (even though I have limited understanding of PHP) is identify the search code in the working Default theme, and put it into the “non-working” theme that exhibits the search problem.

So, here’s the code in the non-working theme’s searchform.php:
<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
<input type="text" value="<?php echo wp_specialchars($search_text, 1); ?>" name="s" id="s" onfocus="if (this.value == 'search blog archives') {this.value = '';}" onblur="if (this.value == '') {this.value = 'search blog archives';}"/>
<input type="submit" id="searchsubmit" value="go" />
</div>
</form>

I don’t think the Javascript bits (this.value and so on) have anything to do with it. What does appear to be important is the form’s action – in this case “echo $_SERVER[‘PHP_SELF’]”. Have a look at how it reads in the Default theme’s searchform.php:

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: