Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i'm trying to put a search page on my site. I thought it would be simple, but I am having no success.

I have put a form in my header.php (which I call in my search.php page (include "header.php")) that looks like that:

<form action="<?php bloginfo("template_directory") ?>/search.php" method="get">
                <input type="text" value="Votre recherche pour:" /> 
                <input type="submit" value="soumettre" />
            </form>

But when I submit the search, I get this fatal error and I don't know what to do.

Hopefully, you will be able to help. Thanks!

Fatal error: Call to undefined function add_action() in C:\wamp\www\wordpress-3.5-fr_FR\wordpress\wp-content\themes\electrobangers\functions.php on line 2

Relevant code: add_action("init", "register_my_menus");

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You form action value is wrong. It should be home_url(). WordPress will pick the search template automatically then.

The search field has to use the name s:

<input type=search name=s>

Otherwise WordPress will not recognize the request as a search request.

The error happens, because you included the functions.php somehow withut using the automatic by WordPress.

share|improve this answer
    
I used bloginfo("url"), because home_url() was not working. Now I can successfully reach the search.php page by submitting search, but my search.php includes a lot more than just the header.php I have included. It includes the same "skeleton" than index.php, with the sidebar and everything. Do you now why it does that? Thank you btw. –  Maxwell Jan 17 '13 at 21:50
    
Ho, nvm, it seems like ti wors now. Thank you! –  Maxwell Jan 17 '13 at 21:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.