Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro S&F not affecting query_posts() function (how?)

Viewing 7 posts - 11 through 17 (of 17 total)
  • Trevor Moderator
    #58392

    Ross, the developer, gave me some advice for you.

    Your loop (which we can’t see) I think may be using the wrong syntax – like $cars_query->results, whereas query_posts replaces the global query

    So your loop might be

    while ( $cars_query->have_posts() ) : $cars_query->the_post();
    

    But it should be

    while ( have_posts() ) : the_post();
    

    If you want the query in a var, you should use new WP_Query() with the same args.
    Just guessing here

    Paddy McCann
    #58405

    Sorry for not providing the loop

    This is the loop that I am using:

    
    if ( have_posts() ) :
    
    	while ( have_posts() ) : the_post();
    
    		do_action( 'cherry_entry_before' );
    
    		<!-- Custom Code Removed -->
    
    		do_action( 'cherry_entry_after' );
    
    	endwhile;
    
    endif; ?>
    

    However, I can tell that the problem is not in the loop because the array that query_posts returned was not affected. Tested by doing a print_r($cars_query);

    Regarding the mode of display, I’ve set it to “Custom”. Here’s a screenshot: http://prntscr.com/cioifw
    You may also refer to this page: http://webheadproj.tk/australian-automotive-group/cars/
    as provided in the screenshot. I am willing to provide logins in a private reply to aid the understanding of the situation. Please inform me if needed.

    Really appreciate the help we’re getting so far.

    Thanks

    Trevor Moderator
    #58409

    Generally, it must not be Custom. If you are writing your own template, it should be As an Archive, or, if it is on a posts archive page, it can be Post archive.

    Get back to me after you try that?

    Paddy McCann
    #58416

    Alright Trevor, is there no existing way of doing it from within a page?

    The reason why I’d like to have it from within a page and not from an archive page is: Unlike and archive page, I’d like to be able to control layout options for the page through utilizing the backend options for the page “Edit Page”.

    I did a test just now. It seems to work fine when I display it via the shortcode.
    Shortcode is returning the results correctly. Is there no way to do exactly what that shortcode is doing behind things? Or modify that shortcode’s display template? or maybe return an array of posts instead of an html?

    Just a few thoughts.

    Will wait for your reply.
    Thanks.

    Trevor Moderator
    #58422

    Ah. My bad 🙁

    One of my (many – according to my wife) failings. I often answer the questions and fail to see the bigger picture.

    It works if you select the Shortcode method, yes? Other than appearance (somewhat basic I admit) what is wrong with using that? The appearance we can fix.

    Paddy McCann
    #58424

    With the displays, I am planning to display other information other than just the title and excerpt. Other information such as details of the car (since we are searching a database of cars here) and beside it, the image of the car.

    If possible, I wish to at least retrieve a list of IDs of the items in the search result so I can get all these custom markup/display done.

    Thanks.

    Paddy McCann
    #58428

    Hey Trevor!

    Good news! I did some poking around in the code of the searchandfilter Shortcode and the docs and came to this:
    do_action('search_filter_query_posts', 96);
    which is found in this page of your docs:
    http://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/

    What I am thinking is it was not doing anything to the query at all for non-archive pages. It was not doing any modifications to the query, unless you let S&F do the query via:
    do_action('search_filter_query_posts', 96);

    So my new markup now is:

    
    <?php
    	/**
    	*	Query Cars
    	*/
    
    	do_action('search_filter_query_posts', 'ID_OF_THE_FORM_HERE');
    
    	if ( have_posts() ) :
    
    		while ( have_posts() ) : the_post();
    
    			do_action( 'cherry_entry_before' );
    
    			echo "Some Template Stuff here.";
    
    			do_action( 'cherry_entry_after' );
    
    		endwhile;
    
    	endif;
    

    I hope this helps others who encounter the same problem with non-archive page templates.

    Thanks for the help Trevor!

    This is resolved now.

Viewing 7 posts - 11 through 17 (of 17 total)

The topic ‘S&F not affecting query_posts() function (how?)’ is closed to new replies.