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 8930991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:00:47+00:00 2026-06-15T09:00:47+00:00

I am creating a wordpress template in which I want to integrate a simple

  • 0

I am creating a wordpress template in which I want to integrate a simple search form. I googled a lot about this in the last 3 days and tried several tutorials but I am afraid there is something I don’t get at all. I have 3 pages for the search: search.php, searchform.php and searchpage.php. All the tutorials I read provide similar code like this:

search.php:

<?php if (have_posts()) : ?>
…
<?php while (have_posts()) : the_post(); ?>
…
<?php endwhile; else: ?>
… <p>The key word <strong><?php the_search_query(); ?></strong> is not on this website.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php include (TEMPLATEPATH . "/searchpage.php"); ?>
<?php endif; ?>

searchform.php:

<?php 
$querystring = esc_attr(apply_filters('the_search_query', get_search_query()));
$searchstring = "Suchbegriff eingeben";
if (empty($querystring)) { $querystring = $searchstring; }
?>

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div>
    <input type="text" name="s" id="s" value="<?php echo $querystring; ?>"
        onblur="if (this.value == '') { this.value = '<?php echo $searchstring; ?>'; }"
        onfocus="if (this.value == '<?php echo $searchstring; ?>') { this.value = ''; }" />
    <input type="submit" id="searchsubmit" value="Suchen" />
</div>
</form>

searchpage.php (adapted from page.php):

<?php
/*
Template Name: Search Page
*/
?>

<div id="content">

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

    <div class="blogpost">
        <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
        <?php $this->posts = $wpdb->get_results($this->request); ?>
    </div> <!-- end class blogpost -->
<?php endwhile; ?>

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

If there is no match with the key word the search works. But if there is a match I only get … … … … … … … as output. I know that must be from the search.php but I have no idea how I can change that. Thanks for your advise and help, I really appreciate it!

  • 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-06-15T09:00:48+00:00Added an answer on June 15, 2026 at 9:00 am

    The important file is search.php, which displays any matching results, or a failure message if there are no matches. Try something like this:

    <?php
    /**
     * Search results page
     */
    ?>
    <?php if ( have_posts() ): ?>
    <h2>Search Results for '<?php echo get_search_query(); ?>'</h2> 
    <ol>
    <?php while ( have_posts() ) : the_post(); ?>
        <li>
                <h2><a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                <time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?> <?php the_time(); ?></time> <?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?>
                <?php the_content(); ?>
        </li>
    <?php endwhile; ?>
    </ol>
    <?php else: ?>
    <h2>No results found for '<?php echo get_search_query(); ?>'</h2>
    <?php endif; ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating my WordPress author.php template page and ran into a little roadblock. I want
Simple question. I'm creating a wordpress theme and I want to display the post
I want to do almost exactly this: http://codex.wordpress.org/Pages#A_Page_of_Posts But Im confused by the last
I am creating a dropdown menu for a Wordpress template and I want the
I'm creating a page in Wordpress via a front end form with the code
I am creating a small utility which will help to rebuild install.php of WordPress.
I'm creating a Wordpress plugin and, being a newbie in the development on this
I am creating a Wordpress website for multi author and want to set user
I've created several helper functions which I use when creating templates for Wordpress. An
I'm creating DataGrid template with rounded corners, but I faced with this problem: Bottom

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.