Hi all. I want to put this:
<?php
$cat = 2;
$category=get_category($cat);
// echo "<pre>"; print_r($category); echo "</pre>";
echo $category->cat_name;
?>
into shortcode.
For that i doing this:
function cat_name_shortcode( $atts, $content = null ) {
extract(shortcode_atts(array(
"name" => '3',
), $atts));
return ' <?php
$cat = ' . $name . ';
$category=get_category($cat);
echo $category->cat_name; ?> ' ;
}
add_shortcode('cat-name', 'cat_name_shortcode');
I using this code in template to view shortcode:
<?php echo do_shortcode('[cat-name name="3"]'); ?>
But i getting this on front end:
cat_name; ?>
What im doing wrong and how i can do that?
Thanks.