Support for Envato Buyers Forums Samsara Search Issue

Viewing 2 reply threads
  • Author
    Posts
    • #5206

      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

    • #5214

      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

    • #5250

      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>
    • #5242

      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>

Viewing 2 reply threads
  • You must be logged in to reply to this topic.