WordPress.org

Ready to get started?Download WordPress

Forums

Ajax WP Query Search Filter
[resolved] Customize search results (11 posts)

  1. Rodni
    Member
    Posted 11 months ago #

    Is there any way to customize the search results page?

    http://wordpress.org/plugins/ajax-wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 11 months ago #

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

  3. Rodni
    Member
    Posted 11 months ago #

    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?

  4. TC.K
    Member
    Plugin Author

    Posted 11 months ago #

    Can you provide me your code?

  5. Rodni
    Member
    Posted 11 months ago #

    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;
    }
  6. TC.K
    Member
    Plugin Author

    Posted 11 months ago #

    Let me check on it first.

  7. Rodni
    Member
    Posted 11 months ago #

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

  8. TC.K
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  9. Rodni
    Member
    Posted 11 months ago #

    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?

  10. TC.K
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  11. Rodni
    Member
    Posted 11 months ago #

    I just found the difference on your code. Look how you commented the "$results ='';" line. That did the trick :)

    Thanks a lot, TC!

Reply

You must log in to post.

About this Plugin

About this Topic