Best Way to Change Search Form
-
wordpress 3.8.1
buddypress 1.9.2the BuddyPress Search form doesn’t work so well for my site since it consists mostly of pages, not posts. It only seems to search members or posts. pages don’t show….
I found the code in my theme that seems to invoke the BuddyPress version of the search function (below). I think that’s what it’s doing anyway.
I’m thinking that i could modify the code below to do the “else” section regardless (do the regular search, not the buddpress version). I could copy the searchform.php to my child theme, edit the code, and that should (I think) do it.
Finally, my question. How would somebody that really knows what they are doing – i’m more of an advanced beginner – make this change? Am I approaching this problem correctly? I don’t want to add any weird code to my site.
<!– searchform.php –>
<?phpglobal $blog_id;
// if this is the main BuddyPress-enabled blog…
if (function_exists( ‘bp_search_form_type_select’ ) AND
BP_ROOT_BLOG == $blog_id) {
// —————————————————————————–
// BuddyPress
// —————————————————————————–?><form action=”<?php echo bp_search_form_action() ?>” method=”post” id=”search-form”>
<label for=”search-terms” class=”accessibly-hidden”><?php _e( ‘Search for:’, ‘commentpress-core’ ); ?></label>
<input type=”text” id=”search-terms” name=”search-terms” value=”<?php echo isset( $_REQUEST[‘s’] ) ? esc_attr( $_REQUEST[‘s’] ) : ”; ?>” /><?php echo bp_search_form_type_select() ?>
<input type=”submit” name=”search-submit” id=”search-submit” value=”<?php _e( ‘Search’, ‘commentpress-core’ ) ?>” />
<?php wp_nonce_field( ‘bp_search_form’ ) ?>
</form><!– #search-form –>
<?php
} else {
// —————————————————————————–
// WordPress
// —————————————————————————–?><form method=”get” id=”searchform” action=”<?php echo site_url(); ?>/”>
<label for=”s”><?php _e(‘Search for:’, ‘commentpress-core’); ?></label>
<input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” />
<input type=”submit” id=”searchsubmit” value=”<?php _e( ‘Search’, ‘commentpress-core’ ); ?>” />
</form>
<?php
}
?>
- The topic ‘Best Way to Change Search Form’ is closed to new replies.