views:

73

answers:

4

I have created a searchfrom.php for wordpress but then it's giving me a false returns you can try the search yourself here

Here is the code for my search form

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<input type="text" class="form-text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" class="goField" />
</form>

Here is the code of my search.php page

get_header(); ?>
  <div id="BodyWrap">
<div id="mainCont">
<?php get_sidebar(); ?>
<div id="mainCopy">

    <div id="content" class="narrowcolumn" role="main">

    <?php if (have_posts()) : ?>

        <h2 class="pagetitle">Search Results</h2>

        <div class="navigation">
            <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
        </div>


        <?php while (have_posts()) : the_post(); ?>

            <div <?php post_class() ?>>
                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
                <small><?php the_time('l, F jS, Y') ?></small>

                <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
            </div>

        <?php endwhile; ?>

        <div class="navigation">
            <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
        </div>

    <?php else : ?>

        <h2 class="center">No posts found. Try a different search?</h2>
        <?php get_search_form(); ?>

    <?php endif; ?>

    </div>
</div>
</div>
</div>
<?php get_footer(); ?>

It does do the search but there are this "at | Uncategorized | No comment" which is not even part of the search term.

A: 

It does do the search but there are this "at | Uncategorized | No comment" which is not even part of the search term.

You'll have to edit your page.php or single.php to exclude the search page from showing the Comments/Categories.

Dremation
can you show me how this is all new to me and also not to great in PHP
kwek-kwek
After looking at your site again, looks like your using the default WordPress search function. Could you post the code to your search.php file?
Dremation
updated my post with the search.php code
kwek-kwek
A: 

Maybe change searchform.php to this?

Michal Kopanski
yes but I am trying to figure out is why does it include "Posted in Uncategorized | Comments Off" if it's not even in the search term.
kwek-kwek
Because your search results are configured to display that information. The search results are a wordpress loop like the index page.If you don't want the into to show, remove it from the loop.Or am I completely off target?
Michal Kopanski
yes but if I remove it in the loop it ould show up empty divs.
kwek-kwek
A: 
jocap
You might want to use preg_match() instead of just checking if the category is equal to the search term.
jocap
Hi thank you for the answer I really don't want to change it I just wante to know why when you do a search e.g. phil on the site it gives out blank list that says this "at | Uncategorized | No comment" please visit the site and do a search "Phil" and you will see the problem. Thank you
kwek-kwek
Actually, no. I see, for example, "Posted in Articles | No Comments »". Does the problem remain if you log out?
jocap
I mean not but how do I remove that "Posted in Uncategorized | Comments Off".. as you can see it shows up even when it is not a search term and not even an article inside it...
kwek-kwek
A: 
Michal Kopanski