WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Search page redirecting to home page (19 posts)

  1. tlacaelelrl
    Member
    Posted 2 years ago #

    Hello!

    I am making a custom theme for my wordpress site in it the single page and home page are now displaying properly, my problem is with the search function, I have added the search form which looks like this:

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
    <div>
    <label for="searchform"></label><input class="searchinput" type="text" value="<?php if(trim(wp_specialchars($s,1))!='') echo trim(wp_specialchars($s,1));else echo ' ';?>" name="searchform" id="searchform" />
    <input type="submit" class="submitinput" name="Submit" value="Search!" />
    </div>
    </form>

    I am assuming my problem is the action in the form but I don't know what to replace it with to be able to load the search.php instead of the home.php, I tried adding /search after the blog's url but that gives me a page not found, I also read the documentation here
    http://codex.wordpress.org/Function_Reference/get_search_form

    but it says there that the action should be pointing to the home url so I am now lost, please help!!!

  2. fwoan
    Member
    Posted 2 years ago #

    Give us an example of what you put into the action attribute when you tried to set it to your search template.

  3. tlacaelelrl
    Member
    Posted 2 years ago #

    fwoan: It is right there in my first post it shows the full search form, the action is bloginfo('url') is that what you asked for?

  4. fwoan
    Member
    Posted 2 years ago #

    No, I'm looking for an example of what you were doing when you described this:

    I tried adding /search after the blog's url but that gives me a page not found

  5. fwoan
    Member
    Posted 2 years ago #

    Basically, your theme should have a search results template that will execute on the submission of the form. Make sure that exists and that you are outputting the correct URL in the action attribute.

  6. tlacaelelrl
    Member
    Posted 2 years ago #

    the search page does exist search.php and even if I have the template only display header footer and a message in the body it goes to the home page, I am using this as the form action bloginfo('url')

    I also tried action="<?php bloginfo('url');?>search"
    I also tried action="<?php bloginfo('url');?>/search"

  7. fwoan
    Member
    Posted 2 years ago #

    try action="<?php bloginfo('url');?>/search.php"

  8. tlacaelelrl
    Member
    Posted 2 years ago #

    this is the search page, I am not doing any results output until I am able to render that page when I hit the search button that is why it is empty, just echo something to know I got there

    <?php
    get_header();
    echo "in the search page";
    get_footer();
    ?>
  9. fwoan
    Member
    Posted 2 years ago #

    Oops, I mean try: action="<?php bloginfo('template_directory');?>/search.php"

  10. tlacaelelrl
    Member
    Posted 2 years ago #

    I did what you recommended
    "try action="<?php bloginfo('url');?>/search.php""
    And this is what I got in the address bar

    http://www.medialifemagazine.com/wordpress/wordpress/search.php?searchform=+some+search&Submit=Search!

    And got 404

  11. tlacaelelrl
    Member
    Posted 2 years ago #

    Tried the second
    bloginfo('template_directory');?>/search.php"

    and got

    PHP Fatal error: Call to undefined function get_header()

    so wordpress is not processing that

    by the way, thank you for all your help!!!

  12. fwoan
    Member
    Posted 2 years ago #

    Well, you have two wordpress directories in that url. Is your site actually set up like that? Or is that incorrect?

  13. fwoan
    Member
    Posted 2 years ago #

    I think the problem goes deeper into what you have defined as your site and wordpress URLs.

  14. tlacaelelrl
    Member
    Posted 2 years ago #

    The directory structure is like that basically is base/wordpress/wordpress/here are the inner wordpress files and folders, the rest of the site works just fine

  15. fwoan
    Member
    Posted 2 years ago #

    I think I'm out of ideas... sorry.

  16. tlacaelelrl
    Member
    Posted 2 years ago #

    Thank you, what I did is add a hidden value in the search form and check the $_GET to see if search is set, now I am trying to figure how to access the search results, I tried with have_posts() but I got no results

  17. tlacaelelrl
    Member
    Posted 2 years ago #

    Got it working, thank you for all your help!!!

  18. kidcardboard
    Member
    Posted 1 year ago #

    I've taken over a site from another developer and I'm having a similar issue. I've created a search page and if I leave the form action as <?php bloginfo('url'); ?> it does the search and uses the search template but the url is http://localhost (not what we or the client want). If I set the action to <?php bloginfo('url'); ?>/search I get page not found, however if I navigate to http://localhost/search is displays the search page with no search results.

    I was able to kinda get it working by using http://localhost/search.php but then the pagination links don't work and if you change to French it breaks (although I could probably fix the French issue with .htaccess, haven't tried that yet).

  19. Andrew
    Forum Moderator
    Posted 1 year ago #

    Kidcardboard, this thread is too old that the discussion has ended.
    If you want to discuss your the issue further, create your own thread.
    [closing topic]

Topic Closed

This topic has been closed to new replies.

About this Topic