Solved

Wordpress search removes navigation menu

Posted on 2011-03-16
14
391 Views
Last Modified: 2012-05-11
Here is a weird one!

I have a search facility on the following website

http://www.bluebean.org.uk/current/

When i search for anything it is fine, however, if i search more than one word (i.e put any spaces in the search) it removes the top nav.

Please can someone shine some light on this subject.

Many Thanks,

Andrew
0
Comment
Question by:Andy6350
  • 8
  • 5
14 Comments
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35155434
It seems you are having a javascript conflict. Try disabling your plug-ins to see if it works. If it does then you can enable them one at a time to find the culprit.
0
 

Author Comment

by:Andy6350
ID: 35156075
I haven't tried that, although when i switch back to the twenty ten theme, the search seems to work fine. So i think its something i have modified in the loop perhaps. Finding out what it is i dont know.

Is it worth attaching my file for you to view?

Thanks,
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35156494
Sure, it could be possible that you have altered a theme file which results in the error. It actually makes more sense because you are able to search for a word without a space in the text. I will look at it for you.
0
 

Author Comment

by:Andy6350
ID: 35156561
I have attached the loop.php file of my site.

Many Thanks, loop.php
0
 
LVL 31

Expert Comment

by:gwkg
ID: 35173885
Is your template using a search.php file?  That is where the search template is.

View the source of the page and try to determine which template is being loaded.  Put a html comment in your template files if you need to.
0
 

Author Comment

by:Andy6350
ID: 35181003
My template does use a search.php file which i dont think i modified at all. When i switch to the twenty ten theme it works fine. Is it work replacing the twenty ten search.php file with my own one and see if it breaks the twenty ten theme?

0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35181278
This is from Perishable Press. You will need to create a custom file named searchform.php and place it in the root of your theme folder. Here is the code for the searchform:
<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><input name="s" type="text" id="s" size="33" maxlength="99" />
<input type="submit" class="submit" value="Search &raquo;" /></p>
</form>

Open in new window

Then you can put this in your theme where you want the search input displayed (sidebar.php, header.php, or wherever):
<?php include (TEMPLATEPATH . "/searchform.php"); ?>

Open in new window


Here is a nice coded search page accomponied with a good page.php template from ThemeShaper   (also know as Automatic):
Here is the search.php:

And here is the page.php (maybe something in your page template has bad code and is causing the problem?
<?php if ( have_posts() ) : ?>
 
                <h1 class="page-title"><?php _e( 'Search Results for: ', 'your-theme' ); ?><span><?php the_search_query(); ?></span></h1>
 
<?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
                <div id="nav-above" class="navigation">
                    <div class="nav-previous"><?php next_posts_link(__( '<span class="meta-nav">&laquo;</span> Older posts', 'your-theme' )) ?></div>
                    <div class="nav-next"><?php previous_posts_link(__( 'Newer posts <span class="meta-nav">&raquo;</span>', 'your-theme' )) ?></div>
                </div><!-- #nav-above -->
<?php } ?>                           
 
<?php while ( have_posts() ) : the_post() ?>
 
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
 
<?php if ( $post->post_type == 'post' ) { ?>
                    <div class="entry-meta">
                        <span class="meta-prep meta-prep-author"><?php _e('By ', 'your-theme'); ?></span>
                        <span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all posts by %s', 'your-theme' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span>
                        <span class="meta-sep"> | </span>
                        <span class="meta-prep meta-prep-entry-date"><?php _e('Published ', 'your-theme'); ?></span>
                        <span class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time( get_option( 'date_format' ) ); ?></abbr></span>
                        <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?>
                    </div><!-- .entry-meta -->
<?php } ?>
 
                    <div class="entry-summary">
<?php the_excerpt( __( 'Continue reading <span class="meta-nav">&raquo;</span>', 'your-theme' )  ); ?>
<?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
                    </div><!-- .entry-summary -->
 
<?php if ( $post->post_type == 'post' ) { ?>
                    <div class="entry-utility">
                        <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'your-theme' ); ?></span><?php echo get_the_category_list(', '); ?></span>
                        <span class="meta-sep"> | </span>
                        <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __('Tagged ', 'your-theme' ) . '</span>', ", ", "</span>\n\t\t\t\t\t\t<span class=\"meta-sep\">|</span>\n" ) ?>
                        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'your-theme' ), __( '1 Comment', 'your-theme' ), __( '% Comments', 'your-theme' ) ) ?></span>
                        <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ) ?>
                    </div><!-- #entry-utility -->
<?php } ?>
                </div><!-- #post-<?php the_ID(); ?> -->
 
<?php endwhile; ?>
 
<?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
                <div id="nav-below" class="navigation">
                    <div class="nav-previous"><?php next_posts_link(__( '<span class="meta-nav">&laquo;</span> Older posts', 'your-theme' )) ?></div>
                    <div class="nav-next"><?php previous_posts_link(__( 'Newer posts <span class="meta-nav">&raquo;</span>', 'your-theme' )) ?></div>
                </div><!-- #nav-below -->
<?php } ?>           
 
<?php else : ?>
 
                <div id="post-0" class="post no-results not-found">
                    <h2 class="entry-title"><?php _e( 'Nothing Found', 'your-theme' ) ?></h2>
                    <div class="entry-content">
                        <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'your-theme' ); ?></p>
    <?php get_search_form(); ?>
                    </div><!-- .entry-content -->
                </div>
 
<?php endif; ?>

Open in new window


And here is the link to the source:
ThemeShaper
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Andy6350
ID: 35210966
when i used the search form above it didnt work, so i copied your search results page code and overwritten my code in my loop file. Still didnt fix it, so i assume the problem lies outside of the loop.php file

head scratching now
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35211317
Did you fix it?

I was trying to diagnose your problem, and it is now working?
0
 

Author Comment

by:Andy6350
ID: 35211388
I have removed the "search everything" plugin that was causing it - but now need a way to exclude a category and pages + including custom fields within my search, the plugin did a great job so gutted :(
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35211884
You can give this a shot, it is from WP-Recipes
http://www.wprecipes.com/how-to-exclude-posts-or-pages-from-search-results
0
 

Author Comment

by:Andy6350
ID: 35213628
I tried that with no success :(
0
 

Accepted Solution

by:
Andy6350 earned 0 total points
ID: 35220925
I found out the error occurs on the newer versions of the plugin, so i installed an older version and now it works fine
0
 

Author Closing Comment

by:Andy6350
ID: 35252843
Appreciated your time and support
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now