Support for Envato Buyers › Forums › Samsara › Search Issue
- This topic has 3 replies, 2 voices, and was last updated 10 years, 8 months ago by FocuxTheme Support.
-
AuthorPosts
-
-
June 4, 2014 at 3:43 pm #5206thyagoresendeMember
Hello,
Great theme guys! I’m running on a small issue though:
My site does not use a portfolio or a blog, but I still need a “search tool” for users to search regular pages on the site.If it’s possible, I’d like to ask for help doing the following:
1 – How can I remove the dropdown in the search page with the blog posts & portfolios options (I’m guessing that’s somewhere in a .php file, but which one)?
2 – How can I make the search page look for text in all pages??Thanks very much and keep up the good work! Cheers
-
June 4, 2014 at 10:54 pm #5214FocuxTheme SupportKeymaster
Hi
1. You need to edit content-slidedown.php file and you will find those search options in the following codes about at line 10 – 13
<select name="post_type" id="post_type"> <option value="post"><?php _e('Blog Posts','Samsara');?></option> <option value="portfolio"><?php _e('Portfolios','Samsara');?></option> <?php if(is_plugin_active('woocommerce/woocommerce.php')):?> <option value="product"><?php _e('Products','Samsara');?></option> <?php endif;?> </select>
2. You need to edit includes/theme-functions.php file, find the following function at line 110 – 120
add_filter( 'get_search_form', 'van_search_form' ); function van_search_form( $form ) { $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" > <div><label class="screen-reader-text" for="s">' . __( 'Search for:','Samsara' ) . '</label> <input type="text" value="' . get_search_query() . '" name="s" id="s" /> <input type="hidden" value="post" name="post_type" id="post_type" /> <input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search','Samsara' ) .'" /> </div> </form>'; return $form; }
Look at this code in the function
<input type="hidden" value="post" name="post_type" id="post_type" />
Change to
<input type="hidden" value="page" name="post_type" id="post_type" />
Then, edit search.php, find the following codes
<?php $post_types='post'; if(isset($_GET['post_type'])){ $post_types=$_GET['post_type']; } if($post_types=='portfolio'){ echo '<div class="portfolio-posts section"> <div class="portfolio-container">'; get_template_part('content','portfolios'); echo '</div> </div>'; }elseif($post_types=='post'){ $limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('post_type=post&s='.$_GET['s'].'&posts_per_page='.$limit.'&paged='.$paged); get_template_part('loop','default'); }
Change to
$limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('post_type=page&s='.$_GET['s'].'&posts_per_page='.$limit.'&paged='.$paged); get_template_part('loop','default');
I strongly suggest you can create your own child theme if you want to change the theme files, otherwise, you can’t update the theme smoothly in the future.
Thanks
-
June 6, 2014 at 9:09 pm #5250FocuxTheme SupportKeymaster
If you want to completely remove the drop menu, I think you should delete all the select HTML code.
<select name="post_type" id="post_type"> <option value="post"><?php _e('Blog Posts','Samsara');?></option> <option value="portfolio"><?php _e('Portfolios','Samsara');?></option> <?php if(is_plugin_active('woocommerce/woocommerce.php')):?> <option value="product"><?php _e('Products','Samsara');?></option> <?php endif;?> </select>
-
June 6, 2014 at 6:04 am #5242thyagoresendeMember
Thanks, I’ve used those customs files in a child theme and the search worked great!
ps: in the content-slideshow.php what I did was just remove the dropdown menu lines, as following:
<option value="post"><?php _e('Blog Posts','Samsara');?></option>
<option value="portfolio"><?php _e('Portfolios','Samsara');?></option>
<?php if(is_plugin_active('woocommerce/woocommerce.php')):?>
<option value="product"><?php _e('Products','Samsara');?></option>
-
-
AuthorPosts
- You must be logged in to reply to this topic.