Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active December 14, 2015 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glueckpress/9850582 to your computer and use it in GitHub Desktop.
Save glueckpress/9850582 to your computer and use it in GitHub Desktop.
[WordPress] Mini plugin to reduce the number of tags displayed in the Tag Cloud widget.
<?php
/**
* Plugin Name: GlückPress Reduce Tags
* Description: Reduce the number of tags displayed in the tag cloud widget.
* Version: 2014.01
* Author: Caspar Hübinger
* Author URI: http://glueckpress.com/
*
*/
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Configure number of tags here.
*/
function glckprss_reduce_tags_to_number() {
return 10; // number of tags to be displayed
}
/**
* Load plugin.
*
*/
function glckprss_reduce_tags() {
add_filter( 'widget_tag_cloud_args', 'glckprss_reduce_tags_tag_cloud_args' );
}
add_action( 'plugins_loaded', 'glckprss_reduce_tags' );
/**
* Pass a custom number of tags to the tag cloud widget.
*
* @param array $args Configuration arguments.
* @return array
*/
function glckprss_reduce_tags_tag_cloud_args( $args ) {
$args['number'] = absint( glckprss_reduce_tags_to_number() );
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment