Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shortcode fpr Category & Tag Desc
- add_shortcode('cat_desc', 'cat_desc_shortcode');
- function cat_desc_shortcode( $atts, $content = null ) {
- $a = shortcode_atts( array(
- 'id' => null,
- 'slug' => null,
- 'title' => 'false',
- 'link' => 'true',
- ), $atts );
- if( $a['id'] ) {
- $cat = get_category( $a['id'] );
- $a['title'] = 'true';
- } elseif( $a['slug'] ) {
- $cat = get_category_by_slug( $a['slug'] );
- $a['title'] = 'true';
- } else {
- $cat = get_the_category()[0];
- }
- if( $cat == null ) return;
- $cat->url = get_category_link( $cat->term_id );
- $output .= '<div class="description">'.$cat->description.'</div>';
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement