Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 708707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:25:16+00:00 2026-05-14T04:25:16+00:00

I have created a searchfrom.php for wordpress but then it’s giving me a false

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:25:16+00:00Added an answer on May 14, 2026 at 4:25 am

    Oh, I see. You want to know why it lists categories even if they don’t match the search term?
    Well, that’s the default WordPress behavior. I guess you could change it, but I don’t see why, actually.

    It is the

    
    Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    

    part in your search.php that displays the categories and comments count. However, if you remove the code above, the categories and comments count will not be shown (even if the categories matches your search term).

    You may replace the code above with this code, if you only want to display the categories if they are the same as the search term:

    
    <?php
    foreach(get_the_category() as $cat){
        if(strtolower($cat->cat_name)==strtolower($_GET['s'])){
            $match = true;
        }
    }
    if($match){ echo 'Posted in '; }
    foreach(get_the_category() as $cat){
        if(strtolower($cat->cat_name)==strtolower($_GET['s'])){
            echo $cat->cat_name;
            echo ', ';
        }
    }
    edit_post_link('Edit', '', ' | ');
    comments_popup_link('No Comments »', '1 Comment »', '% Comments »');
    ?>
    

    It should produce something like this, if the categories match the search term:

    Posted in Category That Matches, Edit | 1 Comment
    

    If the categories don't match the term:

    Edit | 1 Comment
    

    If you don't want the comments count (or Comments Off) to display, remove the comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); line from my code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.