![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/f1735e8503dec866193d7f03d26b98f3-87a1c39.jpg)
Hi,
I have this work in progress : http://next.webstantly.com/blog/ , i need to have a featured post on top of the blog, so i have set up a featured cat, and the client can choose which post to have.
So i have to remove this category from the loop, i have done it like that
add_filter( 'beans_loop_query_args', 'remove_featured_from_loop' );
function remove_featured_from_loop() {
return array(
'cat' => '-41',
);
}
It works, but the problem is on the pagination, if you click on page too, in reality it is page one again...
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/19fc55df0a7382c19e4480349fee60fa-87a1c39.jpg)
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/f1735e8503dec866193d7f03d26b98f3-87a1c39.jpg)
Thank you Mathieu,
It can be an idea, i have never used this function, that's why it didn't cross my mind.
But anyway i would like to know why i have this behaviour, and fix it.
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hey Alex, using sticky post as Mathieu greatly suggested is definitely a good option in your case.
Regarding the pagination issue, you have to set the paged
query argument when using beans_loop_query_args
because it creates a new WP_Query
. So your code would be:
add_filter( 'beans_loop_query_args', 'remove_featured_from_loop' );
function remove_featured_from_loop() {
return array(
'cat' => '-41',
'paged' => get_query_var( 'paged') ? get_query_var( 'paged' ) : 1,
);
}
That said, if this is for the main loop on the page, I would strongly advise to use pre_get_posts
action to modify the main query rather than beans_loop_query_args
which creates a new query. Here is more details about the difference between beans_loop_query_args
and pre_get_posts
.
Have fun,
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/f1735e8503dec866193d7f03d26b98f3-87a1c39.jpg)
Thank you,
It works perfectly ! I have tryed pre_get_posts but it doesn't work
add_action( 'pre_get_posts', 'example_query' );
function example_query( $query ) {
// Modify the main query on the front end only.
if ( $query->is_main_query() && ! is_admin() ) {
$query->set( 'cat', -41 );
}
}
php storm tell me that the methods is_main_query and set are not found...
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hey Alex,
Glad to hear the paged
argument worked for your. Regarding the pre_get_posts
action, where is your snippet located in your child theme?
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/27c64319e1ca198958613305e6ea1b6e-87a1c39.jpg)
HI Alexandra,
my question is off topic but how were you able toapply styling to your Offcanvas menu? Do I modify it in function.php and change the default style in ulit?