Search Bar
-
I posted a request in a “resolved” thread entitled “add search bar” but I think it went under the radar. I can get the search bar to display, using the code supplied in that thread, but the search feature does not work, it returns a good looking page with no results: see side bar at benpasley.com. Help!
Thanks.
-
Have you modified your theme or something? Possibly a plugin is causing this. It’s not an issue with Decode, as far as I know.
Well, I turned off all plugins, loaded the basic search widget from WP and still the search returns a blank page. You can test it easily enough at my site. My modifications to the theme are all in a Child Theme. The CSS is all single entry mods, but I did copy entire .php pages (like footer.php for instance) when I placed them in the Child Theme because I wasn’t sure how to code those lines otherwise.
OK, I can’t see what’s wrong with your site, but I can’t reproduce it myself. What files did you copy into your child theme? Have you made any modifications to them?
Yes, I modded the header, content-page, content-single, footer and content.php files with modest changes for display on the site, nothing huge, but I did copy the entire file to do so.
It’s possible that a change to content.php could be causing this. Can you copy and paste that here?
<?php
/**
* @package Decode
*/
?><?php if ( has_post_format( ‘quote’ ) && get_theme_mod( ‘use_excerpts’, false ) == false && !is_search() ) : ?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<div class=”entry-content”><?php the_content( __( ‘Continue reading <span class=”meta-nav”>→</span>’, ‘decode’ ) ); ?></div>
<?php wp_link_pages( array( ‘before’ => ‘<div class=”page-links”>’ . __( ‘Pages:’, ‘decode’ ), ‘after’ => ‘</div>’ ) ); ?>
<footer class=”entry-meta”>
<?php if (get_theme_mod( ‘enable_comments’, true ) == true ) : ?>
<?php if ( ! post_password_required() && ( comments_open() || ‘0’ != get_comments_number() ) ) : ?>
<div class=”comments-link”><?php comments_popup_link( __( ‘Leave a comment’, ‘decode’ ), __( ‘1 Comment’, ‘decode’ ), __( ‘% Comments’, ‘decode’ ) ); ?></div>
<?php endif; ?>
<?php endif; ?>
<?php edit_post_link( __( ‘Edit’, ‘decode’ ), ‘<span class=”edit-link”>’, ‘</span>’ ); ?>
<?php if (get_theme_mod( ‘show_tags’, false ) == true ) : ?>
<p class=”tags”><?php the_tags(__( ‘Tagged as: ‘, ‘decode’ ),’, ‘); ?></p>
<?php endif; ?>
<?php if (get_theme_mod( ‘show_categories’, false ) == true ) : ?>
<p class=”categories”><?php _e( ‘Categorized in: ‘, ‘decode’) . the_category(‘, ‘); ?></p>
<?php endif; ?>
<p class=”date”><?php decode_posted_on(); ?></p>
</footer><!– .entry-meta –>
</article><!– #post-<?php the_ID(); ?> –><?php elseif ( has_post_format( ‘link’ ) && get_theme_mod( ‘use_excerpts’, false ) == false && !is_search() ): ?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<header class=”entry-header”>
<?php if ( has_post_thumbnail() ) : ?>
” title=”<?php the_title_attribute(); ?>” >
<?php the_post_thumbnail(); ?>
<?php endif; ?>
<div class=”entry-title”><h2><?php decode_print_post_title() ?><?php if ( get_theme_mod( ‘link_post_title_arrow’, false ) == true ) echo ‘<span class=”link-title-arrow”>→</span>’; ?></h2></div>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘above’ ) : ?>
<div class=”entry-meta above-content”>
<p class=”date”><?php decode_posted_on(); ?></p>
</div><!– .entry-meta –>
<?php endif; ?>
</header>
<div class=”entry-content”><?php the_content( __( ‘Continue reading <span class=”meta-nav”>→</span>’, ‘decode’ ) ); ?></div>
<?php wp_link_pages( array( ‘before’ => ‘<div class=”page-links”>’ . __( ‘Pages:’, ‘decode’ ), ‘after’ => ‘</div>’ ) ); ?>
<footer class=”entry-meta”>
<?php if (get_theme_mod( ‘enable_comments’, true ) == true ) : ?>
<?php if ( ! post_password_required() && ( comments_open() || ‘0’ != get_comments_number() ) ) : ?>
<div class=”comments-link <?php echo get_theme_mod( ‘enable_comments’, ” ); ?>”><?php comments_popup_link( __( ‘Leave a comment’, ‘decode’ ), __( ‘1 Comment’, ‘decode’ ), __( ‘% Comments’, ‘decode’ ) ); ?></div>
<?php endif; ?>
<?php endif; ?>
<?php edit_post_link( __( ‘Edit’, ‘decode’ ), ‘<div class=”edit-link”>’, ‘</div>’ ); ?>
<?php if (get_theme_mod( ‘show_tags’, false ) == true ) : ?>
<p class=”tags”><?php the_tags(__( ‘Tagged as: ‘, ‘decode’ ),’, ‘); ?></p>
<?php endif; ?>
<?php if (get_theme_mod( ‘show_categories’, false ) == true ) : ?>
<p class=”categories”><?php _e( ‘Categorized in: ‘, ‘decode’ ) . the_category(‘, ‘); ?></p>
<?php endif; ?>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘below’ ) : ?>
<p class=”date”><?php decode_posted_on(); ?></p>
<?php endif; ?>
</footer><!– .entry-meta –>
</article><!– #post-<?php the_ID(); ?> –><?php elseif ( is_search() ): // Only display Excerpts for Search ?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
“>
<div class=”entry-title”>
<h3><?php decode_search_title_highlight(); ?></h3>
</div>
<div class=”entry-summary”>
<?php decode_search_excerpt_highlight(); ?>
</div><!– .entry-summary –>
<footer class=”entry-meta”>
<?php edit_post_link( __( ‘Edit’, ‘decode’ ), ‘<div class=”edit-link”>’, ‘</div>’ ); ?>
</footer>
</article><!– #post-<?php the_ID(); ?> –><?php elseif ( get_theme_mod( ‘use_excerpts’, false ) == true && !is_sticky() ) : ?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<header class=”entry-header”>
<?php if ( has_post_thumbnail() && get_theme_mod( ‘show_featured_images_on_excerpts’, false ) == true ) : ?>
” title=”<?php the_title_attribute(); ?>” >
<?php the_post_thumbnail(); ?>
<?php endif; ?>
<div class=”entry-title”><h2>“><?php the_title(); ?></h2></div>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘above’ && get_theme_mod( ‘show_entry_date_on_excerpts’, false ) == true ) : ?>
<div class=”entry-meta above-content”>
<p class=”date”><?php decode_posted_on(); ?></p>
</div><!– .entry-meta –>
<?php endif; ?>
</header><!– .entry-header –>
<div class=”entry-summary”>
<?php the_excerpt(); ?>
</div><!– .entry-summary –>
<footer class=”entry-meta”>
“><?php _e(‘Read More…’, ‘decode’); ?>
<?php edit_post_link( __( ‘Edit’, ‘decode’ ), ‘<div class=”edit-link”>’, ‘</div>’ ); ?>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘below’ && get_theme_mod( ‘show_entry_date_on_excerpts’, false ) == true ) : ?>
<p class=”date”><?php decode_posted_on(); ?></p>
<?php endif; ?>
</footer><!– .entry-meta –>
</article><!– #post-<?php the_ID(); ?> –><?php else : ?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<header class=”entry-header”>
<?php if ( has_post_thumbnail() ) : ?>
” title=”<?php the_title_attribute(); ?>” >
<?php the_post_thumbnail(); ?>
<?php endif; ?>
<div class=”entry-title”><h2>“><?php the_title(); ?></h2></div>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘above’ ) : ?>
<div class=”entry-meta above-content”>
<p class=”date”><?php decode_posted_on(); ?></p>
</div><!– .entry-meta –>
<?php endif; ?>
</header><!– .entry-header –>
<div class=”entry-content”><?php the_content( __( ‘Continue reading <span class=”meta-nav”>→</span>’, ‘decode’ ) ); ?></div>
<?php wp_link_pages( array( ‘before’ => ‘<div class=”page-links”>’ . __( ‘Pages:’, ‘decode’ ), ‘after’ => ‘</div>’ ) ); ?>
<footer class=”entry-meta below-content”>
<?php if (get_theme_mod( ‘enable_comments’, true ) == false ) : ?>
<?php if ( ! post_password_required() && ( comments_open() || ‘0’ != get_comments_number() ) ) : ?>
<div class=”comments-link <?php echo get_theme_mod( ‘enable_comments’, ” ); ?>”><?php comments_popup_link( __( ‘Leave a comment’, ‘decode’ ), __( ‘1 Comment’, ‘decode’ ), __( ‘% Comments’, ‘decode’ ) ); ?></div>
<?php endif; ?>
<?php endif; ?>
<?php edit_post_link( __( ‘Edit’, ‘decode’ ), ‘<div class=”edit-link”>’, ‘</div>’ ); ?>
<?php if (get_theme_mod( ‘show_tags’, false ) == true ) : ?>
<p class=”tags”><?php the_tags(__( ‘Tagged as: ‘, ‘decode’ ),’, ‘); ?></p>
<?php endif; ?>
<?php if (get_theme_mod( ‘show_categories’, false ) == true ) : ?>
<p class=”categories”><?php _e( ‘Categorized in: ‘, ‘decode’ ) . the_category(‘, ‘); ?></p>
<?php endif; ?>
<?php if ( get_theme_mod( ‘entry_date_position’, ‘below’ ) == ‘below’ ) : ?>
<p class=”date”><?php decode_posted_on(); ?></p>
<?php endif; ?>
</footer><!– .entry-meta –>
</article><!– #post-<?php the_ID(); ?> –><?php endif; ?>
Scott, I have a coder friend who looked at it and wrote this, do you concur?
I think I found the problem. The search results page is actually coming up with results but not displaying them. If you look at the underlying HTML that results from a search, the link results appear but no content is generated for the link to be applied to. Namely, an empty H3 tag that should contain the title of the search result is generated.
Your’e right in that the content.php contains the errors. I’m pretty sure the bolded text below is the culprit. The tag is generating the right content but the h3 and div with .entery-summary class are not. I think this is because they use funky PHP that is not WordPress standard.
Not enough of a programmer to know why you’re guy went this route. Looks like he coded something more complex rather than using the usual hooks available to us. Here’s a more typical search results blog roll I’ve used for search results before. The part I’ve bolded is how the title content is typically generated in WordPress and what I think would be a start to fixing the problem.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class=”blog-roll-div”>
<h3 class=”blog-h3″>“><?php the_title(); ?></h3>
“><?php the_post_thumbnail( ‘thumbnail’ ); ?>
<?php the_excerpt(); ?>
<hr>
</div>Hope that helps.
Hold on. What version of Decode did you say you were using? I think your child theme is overwriting changes I made a while back and breaking the theme. I’d debase oyour code with the latest version if Decode, especially content.php.
Decode uses
decode_search_title_highlight()anddecode_search_excerpt_highlight()to highlight the search terms in the search results. Did you copy those corresponding functions out offunctions.phpinto your own child theme’sfunctions.php?But the thing is that I don’t use those functions anymore and I have instead removed them.
In Decode, there’s a filter applied to
the_excerpt()andthe_title()that highlights the search terms in the search results. Would those filters be applied to a child theme if the child theme didn’t explicitly callremove_filter()?Yes. Child themes don’t have to overwrite anything in functions.php. That file is special and the Child Theme’s functions.php file only augments it.
It was content.php and my failure to update to your latest version there. I will work to understand how to “update” little edits into the Child Theme in php pages, and not have to grab the whole thing. Thanks, Scott and members.
The topic ‘Search Bar’ is closed to new replies.
