Last active
February 25, 2016 17:13
-
-
Save rosswintle/62e6263ab6bf9f7d5d6b to your computer and use it in GitHub Desktop.
WordPress plugin to add category description to end of the_content
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 | |
/* | |
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