[Resolved] New page for search cannot be viewed
OK so I noticed my searchbar didn’t work in my sidebar that runs througout the site and looked into the root and there was no searchpage.php or even search.php in my theme root. I am very limited in knowledge with php or with wordpress so please bear with me here.
I followed http://codex.wordpress.org/Creating_a_Search_Page from “using the page.php all the way till creating a page titled search using the new template as instructed. The page just cannot be viewed it just redirects me to the homepage, all other pages can be viewed no problem. I also noticed there are some obvious out of date areas on this codex page as well. I’ll give you the code for the searchbar and the new searchpage.php I created. Hopefully after someone can explain to me why my new page cannot be viewed they can help me get the searchbar and search page working.
<div id="searchBox"><form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> <div><label class="screen-reader-text" for="s"></label> <input type="text" value="" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div> </form></div>
my searchpage.php file which I think I did completely wrong
<?php /* Template Name: Search Page */ ?> <?php get_header( 'single' ); ?> <!-- this is the page template --> <div id="singlepostadvert"><img src="<?php bloginfo('template_directory'); ?>/images/advert_example_728x90.png" width="729" height="90" alt="Advert" /></div> <div class="forumpostarea"> <!--Here's where the loop starts--> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="forumpost"><!-- Styles container for each post --> <h2><?php the_title(); ?></h2> <div class="entry"> <?php get_search_form(); ?> </div> </div><!-- Close post --> <?php endwhile; else: ?> <div class="forumpost"> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> </div> <?php endif; ?> </div><!-- Close postarea --> <?php get_footer(); ?>
- The topic ‘[Resolved] New page for search cannot be viewed’ is closed to new replies.