Skip to content

Instantly share code, notes, and snippets.

@trepmal
Created February 13, 2014 05:23
Show Gist options
  • Select an option

  • Save trepmal/8970181 to your computer and use it in GitHub Desktop.

Select an option

Save trepmal/8970181 to your computer and use it in GitHub Desktop.
<?php
/*
* Plugin Name: Min Post Count for Category List
* Plugin URI: trepmal.com
* Description:
* Version:
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* TextDomain:
* DomainPath:
* Network:
*/
add_filter( 'get_the_categories', 'min_post_count_for_category_list' );
function min_post_count_for_category_list( $list ) {
foreach( $list as $k => $term_obj ) {
if ( $term_obj->count < apply_filters( 'min_post_count', 3 ) )
unset( $list[ $k ] );
}
return $list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment