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 Exclude Posts by ID Programmatically

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • kiwicreative
    #217342

    I have a S&F Form and need to find a way to exclude 3 posts from the results programmatically. I know the form settings have the exclude options, but the 3 posts will be changing, so I can’t set them in the settings.

    I have a function that retrieves the 3 IDs I need to exclude and puts them into an array. So trying to figure out a way to say…For a specific S&F form (because I have multiple S&F forms and only need this for one specific one), exclude these 3 posts from results. I feel like there is a filter or hook to do this, I’m just not sure how to create it.

    So lets say my S&F form has an ID of 287

    Then my function that returns an array of post ID’s is excluded_posts(). I’ve tested my function and does properly return an array of the 3 needed IDs

    Any help would be greatly appreciated.

    Trevor Moderator
    #217391

    You would need to use the post__not_in argument for WP Query, and use this in a function inside your child theme’s functions.php file.

    Then add this to our query using this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

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

The forum ‘Search & Filter Pro’ is closed to new topics and replies.