Forums › Forums › Search & Filter Pro › Exclude first post
Tagged: exclude query
- This topic has 3 replies, 3 voices, and was last updated 3 years ago by
Anonymous.
-
Anonymous(Private) October 19, 2020 at 12:51 pm #263365
Hi there,
I‘m building a layout in which a show the first post of a specific query on top of the page. Below I would like to show the filter and results for a query with the same values. Is it possible to exclude that first post as a variable? This ID is a changing ID.
I tried with the offset, but then it breaks the ajax call of the filter.Thanks
Anonymous(Private) April 21, 2022 at 5:07 pm #276546Hi, I’ve a solution for that. You have to use the ‘offset’ parameter.
I added this to function.php:
<?php
function sf_filter_query_args( $query_args, $sfid ) {//if search form ID = 225, the do something with this query
if($sfid==31940)
{
//modify $query_args here before returning it
//only show results within categories with these IDs
$query_args['offset'] = '1';
}
return $query_args;
}
add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 10, 2 );
?>Anonymous(Private) April 21, 2022 at 5:07 pm #276548Sorry for the bad writing:
function sf_filter_query_args( $query_args, $sfid ) { //if search form ID = 225, the do something with this query if($sfid==31940) { //modify $query_args here before returning it //only show results within categories with these IDs $query_args['offset'] = '1'; } return $query_args; } add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 10, 2 );
-
AuthorPosts