Ready to get started?Download WordPress


[resolved] My search works on home page but not sub pages (5 posts)

  1. kensavage
    Posted 6 years ago #

    This doesn't work.
    Comes up with a 404

    But this does:

    I can see that it's the url but why doesn't this work on sub pages. Here's the code calling the search field:

    Search this site:<?php include(TEMPLATEPATH . '/searchform.php'); ?>

    and the include:

    <form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    		<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
    		<input type="submit" id="searchsubmit" value="Go" />
  2. kensavage
    Posted 6 years ago #

    anyone have any ideas?

  3. kensavage
    Posted 6 years ago #

    Is this correct?

    <?php include(TEMPLATEPATH . '/searchform.php'); ?>

  4. moshu
    Posted 6 years ago #

    That one is correct.
    Some servers, however, don't work well with this:
    action="<?php echo $_SERVER['PHP_SELF']; ?>"

    Try a newer version of the searchform file, e.g. from the latest default theme.

  5. kensavage
    Posted 6 years ago #

    that did it Moshu.

    I changes the search.php file to:

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />

Topic Closed

This topic has been closed to new replies.

About this Topic