wordpress自定义文章按自定义分类调用出错

自定义了文章和分类,调用不显示,搜了没有找到,帮忙看看哪里有问题,谢谢

<?php
    $args=array(
        'hide_empty' => 0,
        'exclude'    => 0,
        'taxonomy'   => 'cus_cat',
        );
    $cats=get_categories($args);
    foreach ($cats as $cat){
        $args = array(
        'post_type' => 'cus_post',
        'tax_query' => array(
            array(
                'taxonomy' => 'cus_cat',
                'field'    => 'slug',
                'terms'    => $cat->slug,
            ),
        )
    );
    $posts = new WP_Query( $args);
        if(!empty($posts)){
            echo '<li>'.$the_cat->name.'</li>'
            foreach($posts as $post){
                echo 
                    '<li>
                        <a title="'.wp_trim_words( get_the_excerpt(), 100 ).'" href="'.get_permalink($post->ID).'">'.$post->post_title.'</a>
                    </li>';
                }
                echo '<div class="clear"></div>';
            }
    };
?>
阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题