• So far its doing what I need. However, when using the shortcode like this:

    [wpns_search_form only_search="type,type,type"]

    It doesn’t work because code is not looking to see if there’s multiple types. I made a simple modification to your code and now it works. I can use it to search multiple types using that shortcode. Author, simply edit your code here:

    wp-nice-search/src/core/Results/Results.php

    	
    public function getPostTypes()
    {
       $post_types = array();
       $settings = $this->settings;
    
       if ($settings['wpns_only_search'] != '') 
       {
          // IF THERE'S COMMAS, TREAT AS ARRAY
          if(strpos($settings['wpns_only_search'],',')!==false) 
          {
    
             $type_list = explode(',', $settings['wpns_only_search']);
             
             foreach ($type_list as $type_val) 
             {
    	      $post_types[] = $type_val;
    	 }
          } else {
    
              // IF NOT THEN AS STRING (SINGLE)
    			
              $post_types[] = $settings['wpns_only_search'];
          }
    
    } else {

    Oh and I think it would be much wiser to change your event on the search box to onchange or something because ajax is firing on every key event and that could be troublesome. I changed to min 3.

    Update: other improvements: trim s: $.trim(filter) removing white space and easy to make an array of icons for typical post types and show appropriate icon for the post type in results.

    • This topic was modified 7 years, 7 months ago by webdotcom.
    • This topic was modified 7 years, 7 months ago by webdotcom.
    • This topic was modified 7 years, 7 months ago by webdotcom. Reason: More improvements
  • The topic ‘Good BUT ….’ is closed to new replies.