Created
January 25, 2016 15:56
-
-
Save anonymous/b9f70ad35a9051980eaf to your computer and use it in GitHub Desktop.
WordPress shortcode to display a category description?
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
Try this. Add the code below to your functions.php file - | |
add_shortcode('cat_description', 'my_cat_description_shortcode'); | |
function my_cat_description_shortcode($atts){ | |
$a = shortcode_atts( array( | |
'id' => 0, | |
), $atts ); | |
return category_description($a['id']); | |
} | |
Should you wish to call the shortcode from a template (unnecessary really unless you add more to the shortcode) you can use this code - | |
<?php echo do_shortcode('[cat_description id="' . $category_id . '"]'); ?> | |
Here is some recommended reading for you - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment