最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - custom taxonomies not working

programmeradmin3浏览0评论

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?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论