Advertisement
Beee

custom functions awpqsf

Dec 4th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1. // overwrite ajax search plugin output
  2. add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 2);
  3. function customize_output($results , $args){
  4.     // The Query
  5.     $query = new WP_Query( $args );
  6.     ob_start(); $results ='';
  7.     // The Loop
  8.     if ( $query->have_posts() ) {
  9.  
  10.         echo '<p class="searchnote">We found '.$query->found_posts.' wheels matching your criteria in our database. This doens\'t mean there aren\'t more available.</p>';
  11.         while ( $query->have_posts() ) {
  12.             $query->the_post();
  13.                 $category           = get_the_category();
  14.                 $stylesheetdir  = get_stylesheet_directory_uri();
  15.                 $thumb                  = get_the_post_thumbnail();
  16.                 $dia                        = get_post_meta(get_the_ID(), 'diameter', true);
  17.                 $duro                   = get_post_meta(get_the_ID(), 'durometer', true);
  18.                 // $contactpatch        = get_post_meta(get_the_ID(), 'contactpatch', true);
  19.                 // $position            = get_post_meta(get_the_ID(), 'position', true);
  20.                 global $counter;
  21.                 $counter++;
  22. ?>
  23.         <article <?php post_class( 'p'.$counter ); ?>>
  24. <?php
  25.     if ($thumb) {
  26.         $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail', false, '' );
  27.         $image = $src[0];
  28.     }   else {
  29.         $image = $stylesheetdir.'/assets/img/no-image.png';
  30.     }
  31. ?>         
  32.       <?php get_template_part('templates/wheel-image'); ?>
  33.             <?php // the_content(); ?>
  34.         </article>
  35. <?php
  36.         }
  37.        
  38.         echo '<div class="clear"></div>';
  39.         // echo '<div id="searchbanner">a banner will come here</div>';
  40.  
  41.     } else {
  42.         echo 'No wheels found';
  43.     }
  44.     /* Restore original Post Data */
  45.     wp_reset_postdata();
  46.  
  47.     $results = ob_get_clean();     
  48.     return $results;
  49. }
  50.  
  51. // add AND to taxonomy (category) and free search (werkt)
  52. add_filter('barg_tax_query', 'enable_taxo_key','',3);
  53. function enable_taxo_key($tax_query , $get_tax, $keyword){
  54.     return $get_tax;
  55. }
  56.  
  57. // add AND to meta fields and free search
  58. add_filter('barg_meta_query', 'enable_metafield_key','',3);
  59. function enable_metafield_key($meta_query , $get_meta, $keyword){
  60.     return $get_meta;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement