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" />

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");


1 Answer 1


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.

  • 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.
    – user25893
    Commented Jan 17, 2013 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.