Filters – Chipmunk

Filters

WordPress allows theme developers to make their themes customizable through advanced PHP solution called hooks. There are 2 types of hooks: actions and filters. Chipmunk uses filter functionality to allow advanced users to modify some parts of the theme.

To be able to use them, you’ll need to create a child theme or use our example child theme available to download here.

chipmunk_google_fonts

// Add custom Google Fonts
function chipmunk_custom_google_fonts( $fonts ) {
	$custom_fonts = array(
		'Open Sans Condensed' => 'Open Sans Condensed',
		'Merriweather'        => 'Merriweather',
	);

	return array_merge( $fonts, $custom_fonts );
}

add_filter( 'chipmunk_google_fonts', 'chipmunk_custom_google_fonts', 10, 1 );

chipmunk_socials

// Add custom social profiles
function chipmunk_custom_socials( $socials ) {
	$custom_socials = array(
		'Digg',
	);

	return array_merge( $socials, $custom_socials );
}

add_filter( 'chipmunk_socials', 'chipmunk_custom_socials', 10, 1 );

chipmunk_{type}_excerpt_length

// Change tile excerpt length for posts, resources and collections
function chipmunk_excerpt_length() {
	return 20;
}
add_filter( 'chipmunk_post_excerpt_length', 'chipmunk_excerpt_length', 10, 1 );
add_filter( 'chipmunk_resource_excerpt_length', 'chipmunk_excerpt_length', 10, 1 );
add_filter( 'chipmunk_collection_excerpt_length', 'chipmunk_excerpt_length', 10, 1 );

chipmunk_resource_tabs

// Change resource tabs order
function chipmunk_reorder_resource_tabs() {
	return ['popular', 'latest', 'featured'];
}
add_filter( 'chipmunk_resource_tabs', 'chipmunk_reorder_resource_tabs', 10, 1 );
// Remove the resource tabs completely
function chipmunk_remove_resource_tabs() {
	return [];
}
add_filter( 'chipmunk_resource_tabs', 'chipmunk_remove_resource_tabs', 10, 1 );

chipmunk_submission_required_fields

// Change default required submission fields
function chipmunk_submission_required_fields() {
	return ['name', 'collection'];
}
add_filter( 'chipmunk_submission_required_fields', 'chipmunk_submission_required_fields', 10, 1 );

chipmunk_submission_post_status

// Automatically publish resource submissions
function chipmunk_submission_post_status() {
	return 'publish';
}
add_filter( 'chipmunk_submission_post_status', 'chipmunk_submission_post_status', 10, 1 );

chipmunk_term_max_length

// Change default maximum length of collection/category names in meta tags
function chipmunk_change_term_max_length() {
	return 50; // Use 0 to display full term name
}
add_filter( 'chipmunk_term_max_length', 'chipmunk_change_term_max_length', 10, 1 );

chipmunk_shuffle_terms

// Enable shuffling term names in meta bar
function chipmunk_enable_shuffle_terms() {
	return true;
}
add_filter( 'chipmunk_shuffle_terms', 'chipmunk_enable_shuffle_terms', 10, 1 );