Support » Plugin: Ajax WP Query Search Filter » Customize search results

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author TC.K

    (@wp_dummy)

    Sure, you can use ajax_wpqsf_reoutput to customize the result. Go to this post on how to use the hook.

    I tried with the hook you provided, but for some reason there search form now is always returning “no post found” :S

    Do you think there might be something wrong in the hook’s code?

    Plugin Author TC.K

    (@wp_dummy)

    Can you provide me your code?

    Sure thing! It’s almost the same as the one in the example:

    add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 4);
    function customize_output($results , $arg, $id, $getdata ){
    	// The Query
    	$apiclass = new ajaxwpqsfclass();
    	$query = new WP_Query( $args );
    	ob_start();    $results ='';
    		// The Loop
    		if ( $query->have_posts() ) {
    			while ( $query->have_posts() ) {
    				$query->the_post();
    					echo '<li>'.get_permalink().'</li>';
    			}
    			echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id);
    		} else {
    			echo 'No se han encontrado resultados.';
    		}
    		/* Restore original Post Data */
    		wp_reset_postdata();
    
            $results = ob_get_clean();
                return $results;
    }

    Plugin Author TC.K

    (@wp_dummy)

    Let me check on it first.

    I just tried what you said, but now it’s returning nothing 🙁
    You can check it right here: http://www.rodadosfueguinos.com.ar

    Plugin Author TC.K

    (@wp_dummy)

    Okay, the script is correct, only you have to remove the ‘s’ in the $args – $query = new WP_Query( $args );

    It should be $query = new WP_Query( $arg ); without the ‘s’ in $args.

    I’m still not getting any results after I changed what you told me to :S
    This is my code:

    add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 4);
    function customize_output($results , $arg, $id, $getdata ){
    	// The Query
    	$apiclass = new ajaxwpqsfclass();
    	$query = new WP_Query( $arg );
    	ob_start();    $results ='';
    		// The Loop
    		if ( $query->have_posts() ) {
    			while ( $query->have_posts() ) {
    				$query->the_post();
    					echo '<li>'.get_permalink().'</li>';
    			}
    			echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id);
    		} else {
    			echo 'No se han encontrado resultados.';
    		}
    		/* Restore original Post Data */
    		wp_reset_postdata();
    
            $results = ob_get_clean();
    }

    Any other idea on what could be not working?

    Plugin Author TC.K

    (@wp_dummy)

    weird, it working on my test.

    This is what I use:

    add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 4);
    function customize_output($results , $arg, $id, $getdata ){
    	// The Query
    	$apiclass = new ajaxwpqsfclass();
    	$query = new WP_Query( $arg );
    	ob_start();   //$results ='';
    		// The Loop
    		if ( $query->have_posts() ) {
    			while ( $query->have_posts() ) {
    				$query->the_post();
    					echo '<li>'.get_permalink().'</li>';
    			}
    			echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id);
    		} else {
    			echo 'No se han encontrado resultados.';
    		}
    		/* Restore original Post Data */
    		wp_reset_postdata();
    
            $results = ob_get_clean();
                return $results;
    }

    But seem no difference at all.

    I just found the difference on your code. Look how you commented the “$results =”;” line. That did the trick 🙂

    Thanks a lot, TC!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Customize search results’ is closed to new replies.