I am trying to make a template for my custom taxonomies. I want to create a shortcode so that i can decide how many taxonomy I want to show and some other settings. But the code is not working.
function cat_name_list($atts) {
extract( shortcode_atts( array(
'custom_taxonomy' => 'entertainment_category',
'posts' => 5 ,
'orderby'=>'',
'order'=>'ASC',
), $atts ) );
$terms = get_terms(
array(
'taxonomy' => $custom_taxonomy,
'title_li' => '',
'number' => $posts,
'orderby' => $orderby,
'order' => $order,
)
);
if ( $terms && !is_wp_error( $terms ) ) :
?>
<div class="category_holder">
<?php foreach ( $terms as $term ) { ?>
<?php $image = get_field('category_image', $term->taxonomy.'_'.$term->term_id); ?>
<a href="<?php echo get_term_link($term->slug, $taxonomy); ?>">
<div class="category_boxs" style="background: url(' <?php echo $image['url']; ?>')">
<div class="hover_overlay"></div>
<div class="cat_box_wrap">
<div class="cat_box_title">
<?php echo $term->name; ?>
<span class="pull-right"><i class="fa fa-chevron-right border border_white"></i></span>
<div class="clearfix"></div>
</div>
</div>
</div>
</a>
<?php } ?>
</div>
<?php endif;
}
add_shortcode('category-thumb', 'cat_name_list');
add_filter('widget_text', 'do_shortcode');
What i am doing wrong?