انتخاب برگه

سازه‌های فولادی

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 = ( $a[‘title’] == ‘true’ ) ?

‘;
$output .= ‘

‘.$cat->description.’

‘;
$output .= ( $a[‘link’] == ‘true’ ) ? ‘