Skip to content

Instantly share code, notes, and snippets.

@rosswintle
Last active February 25, 2016 17:13
Show Gist options
  • Save rosswintle/62e6263ab6bf9f7d5d6b to your computer and use it in GitHub Desktop.
Save rosswintle/62e6263ab6bf9f7d5d6b to your computer and use it in GitHub Desktop.
WordPress plugin to add category description to end of the_content
<?php
/*
Plugin Name: Add category description to content
Plugin URI: https://oikos.digital/
Description: Adds the category description to the end of the_content()
Version: 1.0
Author: Ross Wintle/Oikos
Author URI: https://oikos.digital/
*/
if(! function_exists( 'oikos_add_cat_desc') ) {
function id_add_cat_desc($content) {
global $post;
$categories = get_the_category( $post->ID );
if (is_array($categories) && !empty($categories)) {
$cat = current($categories);
$content = $content . $cat->description;
}
return $content;
}
}
add_filter( 'the_content', oikos_add_cat_desc, 1, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment