First, you need to use the proper template include tag. For including the Search Form, you should use:
<?php get_search_form(); ?>
Second, if you don’t need to modify the default Search Form markup, then you don’t need to include “searchform.php”, as the get_search_form() template tag will use the default markup if no “searchform.php” is included in the Theme.
Third: the specific problem you’re having appears to be an issue with your local test environment. Note the specified filepath:
C:\xampp\htdocs\wordpress/wp-content/themes/Xpressphp
See what’s wrong? Your slashes change direction.
Nevertheless: simply get rid of “searchform.php”, call the search form using get_search_form(), and you should be fine.
“Third: the specific problem you’re having appears to be an issue with your local test environment. Note the specified filepath:”
What could be the cause of this problem? How did it occur? How to solve it now?
Thanks for get_search_form()
Hi,
i tried using <?php get_search_form(); ?> and instead of showing my search bar, it just displayed the code of the file.
Code of my searchform.php file:
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div><input type="text" value="<?php if(is_search() ) { the_search_query(); } else { echo 'Search...'; }
?>" name="s" id="s" onfocus="if(this.value=='Search...')this.value='<?php the_search_query(); ?>'"
onblur="if(this.value=='')this.value='Search...'" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
I called this in my header file. Instead of search bar, it showed this on my theme:
��<�form method="get" id="searchform" action="<�?php bloginfo('url'); ?>/"> <�div><�input type="text" value="<�?php if(is_search() ) { the_search_query(); } else { echo 'Search...'; } ?>" name="s" id="s" onfocus="if(this.value=='Search...')this.value='<�?php the_search_query(); ?>'" onblur="if(this.value=='')this.value='Search...'" /> <�input type="submit" id="searchsubmit" value="Search" /> <�/div> <�/form>
What’s happening? What are these strange question marks that appear?
I then removed the searchform.php file from my directory and refreshed the page and voila! The search bar with a search button next to it appeared. But the problem is i don’t like the default search form. I want to style my own form and have other effects. What and how to do?
I also have a modified search.php file.
What to do now?
Do you have some improperly closed PHP tags somewhere in your template files?
EDIT: also, do you have some non-printable characters in your template files?
(Also: the “search.php” template file displays the results of a search query; it should have no bearing on your issue.)
As far as i’m concerned, i have no ‘improperly closed PHP tags’and no ‘non-printable characters’ anywhere in my template files.
But still, just for reassurance, how do i check for the above mentioned errors? Obviously i can’t go through so much of codes in all my files manually, so is there a quick way to find out and check for them?
P.S. If there were improperly closed tags or something, then my theme wouldn’t work, right? But its working. Its only when i include my search form that it shows an error.
One more thing…
All the posts listed in my theme are working perfectly, apart from one post: http://localhost/wordpress/2008/09/05/readability-test/
It was working properly before but now, when i open that page, only the header file loads, breadcrumb is broken, and no sidebar and footer. It shows the following error:
Catchable fatal error: Object of class WP_Error could not be converted to string in C:\xampp\htdocs\wordpress\wp-content\themes\Xpress\functions.php on line 385
Line 385 on my functions.php is this:
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
This line 385 is the code for breadcrumbs. What could be the error?
Is this breadcrumb issue on only 1 particular post problem in any way related to my search form problem?
Please help!
Thanks!