Looking for support? You can access the support system via your account.
Mattieu Moreau
Forum Replies Created
-
Mattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 4:11 pm #215832This reply has been marked as private.Mattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 4:03 pm #215826This reply has been marked as private.Mattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 3:54 pm #215824It seems to work yes, thanks.
Can you please not close the ticket, in case something is still wrong ?
I have to run a few tests
thanksMattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 3:48 pm #215820This reply has been marked as private.Mattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 3:46 pm #215818This reply has been marked as private.Mattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 2:58 pm #215797sorry but I don’t understand your reply, can you be more specific please ?
where do I have to ass this condition ?
thanksMattieu Moreau in reply to:
pre_get_posts adding condition to exclude search result page(Private) July 9, 2019 at 12:48 pm #215780thanks for your replay, but it’s not working… here is my full code, I don’t understand what’s wrong. search results page as an archive should behave like archive page. When I filter the category “cat_1” for example, I should get the same result as when I’m on the “cat_1” archive page, but its not the case, can you please let me know what’s wrong with my code ? thanks
add_action(‘pre_get_posts’, ‘myprefix_query_offset’, 1 );
function myprefix_query_offset(&$query) {
if(is_admin()) return;
if (is_home() && $query->is_main_query() && !is_archive()){
// This is my front Page
//First, define your desired offset…
$offset = 2;//Next, determine how many posts per page you want (we’ll use WordPress’s settings)
$ppp = get_option(‘posts_per_page’);//Next, detect and handle pagination…
if ( $query->is_paged ) {
//Manually determine page query offset (offset + current page (minus one) x posts per page)
$page_offset = $offset + ( ($query->query_vars[‘paged’] – 1) * $ppp );//Apply adjust page offset
$query->set(‘offset’, $page_offset );}
else {
//This is the first page. Just use the offset…
$query->set(‘offset’,$offset);}
} else {
return;
}
}
Mattieu Moreau in reply to:
search posts by tags and adf field(Private) March 13, 2019 at 7:15 pm #205077This reply has been marked as private. -
AuthorPosts