• SkyWayne

    (@skywayne)


    Hi everyone,

    The site I’m working on is http://www.mwpatton.com

    When I enter a search on the site (e.g. try the term “homestead”), the first search result appears okay, but then as you scroll down the search results page, you’ll see that the results are jumbled in a really weird way.

    I have no idea how to fix this.

    Any suggestions?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Your messed up search result items are missing a couple of <div> elements with the “column”, “sevencol” and “twocol” classes for each item, see the screenshot: http://snag.gy/FP4vW.jpg

    Is there no way you can contact your theme’s authors/ vendors?

    Thread Starter SkyWayne

    (@skywayne)

    Thank you SO much for your reply.

    There isn’t any way for me to contact the person who built my site. I paid to have the site built. The guy did a horrible job and then disappeared. I’ve basically been trying to fix the broken pieces and have been learning as I go. It’s been a painfully slow process.

    Not sure what I can do at this point. Any suggestions on where and how I can put the required <div> elements in place?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Really don’t know since it’s a custom built theme. We usually ask that people use a theme from WordPress.org, http://wordpress.org/themes/ because they’re all built to the same standard and their code is easily accessible: http://themes.svn.wordpress.org/

    There is a really dirty way of adding those <div>s which we might help with.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Actually that’s not the issue, I was being blind

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You’re just missing a class of “post” on the each search result, but still I have no idea how to resolve that properly in your theme.

    Are you interested in the rubbish way to resolve this?

    Thread Starter SkyWayne

    (@skywayne)

    The guy who built my site actually purchased the theme from themeforest, so it’s not custom built.

    Anyhow, I’m interested in any solution that won’t increase my site’s load time, since it is already painfully slow . . . .

    That’s a “Yes” to your rubbish solution.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I’m sorry but the rubbish solution will increase loading time.

    Thread Starter SkyWayne

    (@skywayne)

    It’s still okay . . .

    What do you suggest?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Using JavaScript to add the “post” class in, so the easiest way would be to use a plugin that allows you to add custom JS straight to a page, e.g; http://wordpress.org/plugins/custom-js-css/

    Then add this JS:

    jQuery(document).ready(function($) {
     $('.search-results #content article').addClass('post');
    });

    Thread Starter SkyWayne

    (@skywayne)

    Okay, I’m just unclear on what page I would that JS.

    Is there a place in the editor that I can add it to take care of the problem, or would I add that JS in the plugin and then apply it to all pages (with the assumption that search results are displayed on a page)?

    Thread Starter SkyWayne

    (@skywayne)

    Is there any way for me to standardize the code that’s in my theme so that it conforms and has the missing class of “post” that you mentioned?

    Here is the code from Search.php (I can also provide the code from Searchform.php if needed):

    <?php get_header() ?>
    <div class="row">
    	<!-- content -->
    	<div id="content" class="column ninecol">
    		<?php if (have_posts()) : ?>
    			<?php switch_breadcrumbs(); ?>
    			<?php while (have_posts()) : the_post(); ?>
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    				 <?php
    			        $format = get_post_format();
    			        if (false === $format) $format = 'standard';
    		        ?>
    				<?php get_template_part('content', $format); ?>
    				</article>
    			<?php endwhile; ?>
    			<?php switch_content_nav(); ?>
    		<?php else : ?>
    			<article id="post-0" <?php post_class() ?>>
    				<header>
    					<h1 class="entry-title"><?php _e('Nothing Found', 'switch'); ?></h1>
    				</header>
    				<div class="entry-content">
    					<p><?php _e('Sorry, but no entries matched your search criteria. Please make sure all words are spelled correctly or try again with some different keywords.', 'switch' ); ?></p>
    				</div>
    			</article>
    		<?php endif; ?>
    	</div>
    	<!-- /content -->
    	<?php get_sidebar() ?>
    </div><!-- /row -->
    <?php get_footer() ?>

    Here is the code that is in the header:

    <div id="mainmenu">
    			<div class="container">
    				<div id="togglemenu"><a href="#">Browse or search website</a></div>
    				<nav>
    					<?php
    						if (has_nav_menu('main-menu')) {
    							wp_nav_menu(array('theme_location' => 'main-menu', 'container' => '', 'menu_class' => 'sf-menu'));
    						} else {
    					?>
    					<ul class="sf-menu">
    						<?php wp_list_pages('title_li='); ?>
    					</ul>
    					<?php } ?>
                                              <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    				</nav>
    			</div>
    		</div>
    	</header>
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Please don’t duplicate your thread.

    Thread Starter SkyWayne

    (@skywayne)

    The question was not answered over here, so I’m not sure what I was supposed to do. I apologize if it was a breach of decorum, but Andi was actually helping solve my issue over at the other thread. Please reopen it.

    What I really need to understand is how to delete the page class from my search results. We were in the middle of discussing that issue.

    Andi Saleh

    (@bindanaku)

    That’s okay, I’ll continue it here. 🙂

    Past this into your functions.php file. This should reset the search results to only display posts.

    // Custom search filter
    function SearchFilter($query) {
    	if ($query->is_search) {
    		$query->set('post_type', array( 'post' ));
    	}
    	return $query;
    }
    add_filter('pre_get_posts','SearchFilter');

    Hope that helped! 🙂

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The question was not answered over here

    You mean the question wasn’t answered within a certain time period? I understand that you probably have a full time job and reasonably could not respond back until 2 days after my prior response, but that consideration needs to be applied to us too. We can’t answer within time limits for the same reason.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Search Results Page Jumbled’ is closed to new replies.