Support Forums

There is a new way to get support - via the support tab in your account.

Our support systems are changing, for the better. You'll be able to manage all your support requests from your account, and respond to any tickets via email.

These support forums are now closed - existing tickets will be closed after a month.

Forums Forums Search & Filter Pro Get first result of S&F (Using a shortcode)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Noeste IJver


    We have set up a page with S&F with the display results method ‘Using a shortcode’.

    Before the shortcode is executed, I would like to get the first result of the query (I want to display the first item as a highlight before the complete results).

    I thought I could get the results via:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(100773)->current_query();

    But it seems there are no results in this object.

    Is there a way to retrieve the first item of a query from the shortcode method?

    Thanks in advance!

    Trevor Moderator

    That array fetches the search parameters array, not the results array.

    Using the Shortcode display method, you will be using the results.php template, and this follows standard WordPress Codex coding.

    All you would need to do is set set a counter variable before the while loop starts, e.g.

    $post_counter = 0;

    Then, in the first line inside the while loop, increment that by 1:


    I think that would do it. Then use an If to test if it equals 1 and do special HTML, otherwise do normal.

    if ( $post_counter == 1 ) :

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.