WordPress.org

Support

Support » How-To and Troubleshooting » Search location

Search location

  • On my site, the search works fine when you’re on my “home” view. However, when you go onto a page that I created, the search seems to fail. How can I get it so that if I’m trying to search on a page instead of my main page, it’ll search the main pages?

    I think it has something to do wtih the fact that I’m now in www. myurl.com/pages/ instead of www. myurl.com so it can’t search properly. Anyone know how I can fix this? Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Go into the search’s form tag (in page.php if you’re using this for your Pages template) and change the action value to:

    action="/"

    or:

    action="/index.php"

    <form id=”searchform” method=”get” action=”<?php echo $PHP_SELF; ?>”>

    is what I had before, after changing the action to “/” or “/index.php” the search function breaks.

    My search function is located in my sidebar.php file which is called on by everything.

    Hmm. The action attribute just points to the file/script the search is to occur off of, which for WordPress is index.php. So using “/” or “/index.php” *should* be all one need do…

    I just tried this in the default theme (which also has search in the sidebar, but loads the search form from searchform.php) on a test site with no problems.

    hmm, i’m currently using a “search.php” page for my searches to show up, coudl taht be affecting it at all?

    Mayhaps. Does pointing the action value at search.php work?

    heh, i tried /search.php and that didn’t work, and then tried /wp-contents/themes/taibros/search.php and that didn’t work iether.

    Ok…what’s in search.php? Is there a WP loop for the posts to display? As I noted above, I had no difficulty resetting the action, so I’m not sure why you’re running into a problem.

    my search.php file basically redirects to my archives.php file which just tells it how I want it to show up.

    weird, i just tried /index.php even though I know I tried it before with itnot working, and it worked. Thanks for the help!

    Thanks for the help on this. Make sure you edit where it appears on the page vs the searchform.php

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Search location’ is closed to new replies.