• Resolved giggliepig

    (@giggliepig)


    I just want my search results to display in the content area like the rest of the pages. When I try searching for any term (e.g. ‘video’), results do show up, but the entire layout shifts/moves to the right.

    Here is the link to the site, and you’ll see what I mean…
    https://www.djknocturnal.com/

    I’ve been trying to see if anyone else has had the same issue, but I can’t seem to find anything.

    Is it my CSS styling? or am I using the wrong command when posting the query?

    The code I’ve used in my Search Results Page (search.php)

    <h2 class="pagetitle">Search Result for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' &mdash; '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2>
    
                    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
                    <div class="post" id="post-<?php the_ID(); ?>">
    
                    <h3 id="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <br />
    
                        <div class="entry" >
                        <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
                          <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
                        </div>
    
                    </div>
    
                    <?php endwhile; endif; ?>

    Any help would be greatly appreciated. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • It’s a CSS a problem, likely. I took a quick look at your code, and here’s my guess. In style.css, find this code:

    .search {
    display:block;
    float:right;
    height:35px;
    margin-bottom:0;
    margin-left:0;
    margin-right:0;
    margin-top:0;
    padding-right:30px;
    position:relative;
    }

    Delete the second rule: “float: right;”

    See if it makes any difference.

    this is a conflict of the automatic generated body_class .search and the class of the search form.

    you can solve the problem if you change the first line of the code, rightly identified and quoted by @chellycat, to form.search – no further changes.

    Thread Starter giggliepig

    (@giggliepig)

    Thanks chellycat & alchymyth! Great help!

    Here was my solution:

    1. I removed float: right from .search class from my stylesheet
    2. added a new class called .searcharea to the stylesheet
    3. copy everything that was in the .search class to the .searcharea and adding float: right
    4. in the search.php file, I changed the .search class to .searcharea

    … and voila!

    I didn’t realize the search.php and searchform.php was sharing the same .search class in the <div> tag.

    Thanks again! You guys are geniuses! ^_____^

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘search.php results shifted’ is closed to new replies.