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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:13:37+00:00 2026-06-17T10:13:37+00:00

in wordpress in search.php I have this.. get_header(); ?> …html/css <?php if ( have_posts()

  • 0

in wordpress in search.php I have this..

get_header(); ?>
...html/css
 <?php if ( have_posts() ) : ?>   
 <?php while (have_posts()) : the_post(); 
 ...loop stuff
 <?php endwhile; ?>
 <?php wp_pagenavi(); ?>
 <?php else : ?>
 <h3><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'hartyinternational' ); ?></h3>
                    <div class="nothing-found"><?php get_search_form(); ?></div>
    <?php endif; ?>
   <?php wp_reset_query(); ?>

then I have built my own sidebar with WP_Query loops,
e.g.

    if ( have_posts() ) :
$counter = 0;

            $the_query =  new WP_Query( array( 'posts_per_page' => 5, 'cat' => 4 ) );
            while ($the_query->have_posts() ) : $the_query->the_post(); 
            $counter++;
            if ( $counter == 1 || $counter == 3 || $counter == 5   ){
            ?>
            <a href="<?php the_permalink(); ?>"><div class="recent-position-single"><?php the_title();  ?></div> </a>
        <?php }
            else {
            ?> <a href="<?php the_permalink(); ?>"><div class="recent-position-single darker-shade"><?php the_title();  ?></div> </a>
        <?php }



            endwhile;
 wp_reset_query();
 endif; 
 wp_reset_postdata(); ?>

and another similar one,
these work completely fine when search results are found, but when no results are found the loops fail to load any content, any suggestions?

It doesnt seem like a situation where there is a loop within a loop or anything like that, I cant seem to figure out what could be wrong, any help would be great thanks.

  • 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-17T10:13:38+00:00Added an answer on June 17, 2026 at 10:13 am

    I removed if ( have_posts() ): from my queries and that resolved the issue.

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

Sidebar

Related Questions

I have a custom search engine on a non-wordpress page. This search engine searches
what I have: a google search form (displayed on all pages) a wordpress page
WordPress allows theme designers to place a 404.php file in their theme's directory. This
I have this code below: <?php function wp_copickpage() { color_option_update(); ?> <form method=POST action=>
I have a search on the front of wordpress, it needs to be replaced
I have made a placeholder web form: <input type=text value=Search onfocus=if (this.value == 'Search')
I've been struggling with Logging in Wordpress for a while now with CURL (PHP).
I have a problem with my wordpress theme, the functions.php file ouputs ome bad
I have created a search form and search.php file to display the result. The
I have this function I created to give my wordpress site a body tag...

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.