Title: Ignore sticky posts
Last modified: August 21, 2016

---

# Ignore sticky posts

 *  Resolved [Sammy Nordström](https://wordpress.org/support/users/samface/)
 * (@samface)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/ignore-sticky-posts/)
 * This plugin could really use an equivalent of the “ignore_sticky_posts” argument
   in WordPress core. For me, it doesn’t really make much sense to have sticky posts
   in the groups widget, for example. In lack of a better way of achieving this,
   I came up with the following solution in my functions.php:
 *     ```
       if (class_exists('BP_Sticky_Groups') && !is_admin() ) {
   
       	remove_filter( 'bp_groups_get_paged_groups_sql', array( BP_Sticky_Groups::instance(), 'alter_bp_groups_query' ), 10, 2 );
   
       	function allow_sticky_groups() {
       		add_filter( 'bp_groups_get_paged_groups_sql', array( BP_Sticky_Groups::instance(), 'alter_bp_groups_query' ), 10, 2 );
       	}
       	add_action('bp_before_groups_loop', 'allow_sticky_groups');
   
       	function disallow_sticky_groups() {
       		remove_filter( 'bp_groups_get_paged_groups_sql', array( BP_Sticky_Groups::instance(), 'alter_bp_groups_query' ), 10, 2 );
       	}
       	add_action('bp_after_groups_loop', 'disallow_sticky_groups');
   
       }
       ```
   
 * I hope that helps someone and/or maybe even encourages the plugin author to implement
   a neater solution. 🙂
 * [https://wordpress.org/plugins/bp-sticky-groups/](https://wordpress.org/plugins/bp-sticky-groups/)

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

 *  Thread Starter [Sammy Nordström](https://wordpress.org/support/users/samface/)
 * (@samface)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/ignore-sticky-posts/#post-4974772)
 * That didn’t work entirely as expected. As it turns out, you need to do it a bit
   differently to ignore sticky posts in Ajax requests as well. I ended up doing
   it as a plugin in order to hook into the right actions and filters, like this:
 *     ```
       <?php
       /*
       Plugin Name: BP Ignore Sticky Groups
       Description: A plugin to ignore sticky groups everywhere except on the groups page
       Version: 1.0
       Requires at least: 3.6
       Tested up to: 3.8
       Author: samface, angrycreative
       Author URI: http://angrycreative.se
       License: GPLv2
       Network: true
       Text Domain: bp-ignore-sticky-groups
       Domain Path: /languages/
       */
       function bp_ignore_sticky_groups() {
       	$bp =  buddypress();
   
       	if( bp_is_active( 'groups' ) && class_exists('BP_Sticky_Groups') ) {
   
       		if( empty( $bp->groups->extend ) )
       			$bp->groups->extend = new stdClass();
   
       		if( empty( $bp->groups->extend->bp_sticky_groups ) )
       			$bp->groups->extend->bp_sticky_groups = BP_Sticky_Groups::instance();
   
       		function allow_sticky_groups() {
       			if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
       				remove_action( 'bp_groups_get_paged_groups_sql', 'disallow_sticky_groups', 1, 1 );
       				add_filter( 'bp_groups_get_paged_groups_sql', array( BP_Sticky_Groups::instance(), 'alter_bp_groups_query' ), 10, 2 );
       			}
       		}
   
       		function disallow_sticky_groups( $sql = "" ) {
       			if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
       				remove_filter( 'bp_groups_get_paged_groups_sql', array( BP_Sticky_Groups::instance(), 'alter_bp_groups_query' ), 10 );
       				add_action( 'bp_groups_get_paged_groups_sql', 'disallow_sticky_groups', 1, 1 );
       			}
       			return $sql;
       		}
   
       		add_action( 'bp_before_groups_loop', 'allow_sticky_groups', 1 );
       		add_action( 'bp_after_groups_loop', 'disallow_sticky_groups', 1 );
   
       		add_action( 'bp_groups_get_paged_groups_sql', 'disallow_sticky_groups', 1, 1 );
       	}
   
       }
   
       add_action( 'bp_include', 'bp_ignore_sticky_groups' );
       ```
   
 * Preferrably the Sticky Posts plugin would enable the site admin to choose when
   and where the sticky posts should be applied, but the above solution does the
   trick for me right now.
 *  [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * (@imath)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/ignore-sticky-posts/#post-4974849)
 * hi [@samface](https://wordpress.org/support/users/samface/)
 * Thanks for your interest and for sharing, i’ll try to look at it more carefully
   as soon as i can.

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

The topic ‘Ignore sticky posts’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bp-sticky-groups_334350.svg)
 * [BP Sticky Groups](https://wordpress.org/plugins/bp-sticky-groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bp-sticky-groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bp-sticky-groups/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-sticky-groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-sticky-groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-sticky-groups/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/ignore-sticky-posts/#post-4974849)
 * Status: resolved