This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Force Uppercase Search

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #27298
    humblehumans86humblehumans86
    Participant

    Ernest you continue to provide amazing customer support for this product. Worked like a charm just had to
    update the Custom Post Type name ‘product_cpt’ and add the return for the results. behold ….

    p.s. Good to mark resolved on all fronts! Thank you again.

    
    add_filter('asp_results', 'asp_search_result_interchange', 10, 1);
    function asp_search_result_interchange($results) {
    	// Loop through results
    	foreach ( $results as $k => &$r ) {
    		// Check if this is a product
    		if ( isset($r->post_type) && $r->post_type == 'product_cpt' ) {
    			// Get Taxonomy Term IDs based on Post ID of Search Result
    			$term_ids = wp_get_post_terms( $r->id, 'interchange_ct', array(
    				'fields'  => 'ids'
    			));
    
    			//  Get Taxonomy Term objects based on applicable Term IDs
    			$terms = get_terms( 'interchange_ct', array(
    				'include'    => $term_ids,
    				'orderby'    => 'term_order',
    				'order'      => 'ASC',
    				'hide_empty' => true
    			) );
    		  
    			// Create array to store unique Term Names
    			$list = array();
    
    			// Add Term Name to list if unique
    			foreach ( $terms as $term ) {
    				if ($term->parent > 0 && $term->name !==$product_name && !in_array($term->name, $list) ) {
    				  $list[] =  esc_html( $term->name );
    				}
    			}
    
    			// Add the imploded list of terms to the results content
    			if (!empty($list)) {
    				$r->content = implode( ', ', $list ) . '<br>' . $r->content;
    			}
    		}
    
      }
      
      return $results;
    }
    
    #27311
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 2 posts - 16 through 17 (of 17 total)
  • The topic ‘Force Uppercase Search’ is closed to new replies.