Last active
November 23, 2019 10:58
-
-
Save barryhughes/1d52e7562e5d2e6f5121981a4babdd36 to your computer and use it in GitHub Desktop.
bbPress 2.6.x: don't allow "bumped" topics to surface to the top.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Order bbPress topic archives by post date (date created), not by last activity. | |
* | |
* This can be added either within a standalone plugin or to a theme's functions.php | |
* file. | |
* | |
* @param array $args | |
* | |
* @return array | |
*/ | |
add_filter( 'bbp_after_has_topics_parse_args', function( array $args ): array { | |
// Normally bbPress sorts topics by last active (which is stored as meta data). Undo this. | |
unset( $args['meta_key'], $args['meta_type'] ); | |
// Default ordering is DESC, so all we typically need to do here is switch to ordering | |
// by post date (date created). | |
$args['orderby'] = 'date'; | |
return $args; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment