Search Results Cut Short
-
I have a search results page that connects to a loop.php. Currently, when I type the word “roses” into my search box, I should be getting 5 post results, but I am only able to see 4 posts. I know this is not being chopped off at the top, because I have checked the order of the posts. The posts should display thus, from first to last: “Fire Blight”, “Autumn: Better”, “Bouquets and”, “Autumn Musings”, and “Last Projects and Plant Arrivals”. (If I type any search word that yields more than 4 results this will do the same, but for the purpose of this experiment I am limiting the search to “roses” because I still have much of the site marked private.)
The search results are supposed to replace the blogfeed found in the gray box to the right of the screen, but are currently displaying a chopped up version in the gray box and yet are fully displayed in the blue section in the center of the screen. That center portion is reserved for whatever post the reader happens to be viewing, and the results should only display in the gray box, replacing the blog feed.
I have looked at the CSS, and there doesn’t seem to be any trouble there. I also have played around a bit with the function code, which seems to either make no difference or make it worse. I also have the Reading section of the site marked to display at least 10 posts. I am almost 100% certain I have made a rookie error in either the search.php file or the loop.php file, but I am not sure what it is. I am including both codes here, as well as the pagination.php file. Thanks for the help in advance.
Search
<?php get_header(); ?> <div id="mySidenav" class="sidenav" style="background-image: url('gard.jpg')"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a> <?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?> </div> <div id="sidebar"> <div id="top"> <div id="menucontainer" cursor:"pointer" onclick="openNav()"> <p> Menu </p> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> </div> <div id="middle" style="background-image: url('gard.jpg')"></div> <div id="bottom"></div> </div> <div id="center"> <header> <!-- post title --> <div id="excerptbox"> <?php theme1wp_excerpt('theme1wp_index'); ?> </div> <div id="borderboxtext"> <!-- post title --> <div id="titletextbox"> <?php the_title(); ?> <?php $subtitle = get_post_meta($post->ID, 'subtitle', true); if ($subtitle !== '') {echo '<p>' . $subtitle . '</p>'; } ?> </div> <!-- /post title --> </div> <!-- /post title --> <!-- post thumbnail --> <div id="headpic"> <?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); // Fullsize image for the single post ?> </a> <?php endif; ?> </div> <!-- /post thumbnail --> </header> <div id="post"> <?php if (have_posts()): while (have_posts()) : the_post(); ?> <!-- article --> <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <!-- post details --> <span class="date"><?php the_time('F j, Y'); ?></span> <!-- /post details --> <?php the_content(); // Dynamic Content ?> <?php the_tags( __( 'Tags: ', 'theme1' ), ', ', '<br>'); // Separated by commas with a line break at the end ?> </span> <!-- /article --> <?php endwhile; ?> <?php else: ?> <!-- article --> <article> <h1><?php _e( 'Sorry, nothing to display.', 'theme1' ); ?></h1> </article> <!-- /article --> <?php endif; ?> </div> <div id="comments"> <?php comments_template(); ?> </div> </div> <footer> <p class="copyright"> © 2016 - <?php echo date('Y'); ?> Copyright <?php bloginfo('name'); ?>. </p> <p> This site is meant for entertainment purposes only and is not intended to replace professional knowledge. </p> </footer> </div> <div id="rightcontainer"> <button id="down" onclick="scrollDown()" onmouseenter="Highlight1()">▼</button> <button id="up" onclick="scrollUp()" onmouseenter="Highlight2()">▲</button> <h1><?php echo sprintf( __( '%s Search Results for ', 'theme1' ), $wp_query->found_posts ); echo get_search_query();?></h1> <?php get_template_part('loop'); ?> <?php get_template_part('pagination'); ?> </div> </div> <?php get_footer(); ?>
Loop
<div id="blogcontainer" onmouseover="RollOff1()" onmouseout="RollOff2()"> <?php if (have_posts()): while (have_posts()) : the_post(); ?> <div id="postcontainer"> <!-- post thumbnail --> <div class="thumb"> <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(array(100,100)); // Declare pixel size you need inside the array ?> </a> <?php endif; ?> </div><!-- /post thumbnail --> <div class="topblock"> <div class="titleblock"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </div> <div class="moreblock"> <a href="<?php the_permalink(); ?>">MORE ></a></div> </div> <div class="block"> <div class="date"><p><span class="date"><?php the_time('F j, Y'); ?></span></p></div> <?php html5wp_excerpt('theme1wp_index'); // Build your custom callback length in functions.php ?> </div> <!-- /post details --> </div> <!-- /article --> <?php endwhile; ?> <?php else: ?> <!-- article --> <h2><?php _e( 'Sorry, nothing to display.', 'theme1' ); ?></h2> <?php endif; ?> </div> </div> <?php get_footer(); ?>
Pagination
<div class="pagination"> <?php theme1wp_pagination(); ?> </div>'
This is the pagination function in the function.php file
function theme1wp_pagination() { global $wp_query; $big = 999999999; echo paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages )); }
The page I need help with: [log in to see the link]
- The topic ‘Search Results Cut Short’ is closed to new replies.