在 Bootstrap 轮播中显示自定义帖子类型分类法

问题描述

我已经搜索并尝试了所有方法,但似乎无法解决这个问题。我正在尝试在引导轮播中显示自定义分类法(项目类别)。这是一个自定义的帖子类型分类法。我找到了几个这样的例子,但无法让它发挥作用。

这是我的代码

 $cat_terms = array(
    'post_type' => 'project','tax_query' => array(
        array(
            'taxonomy' => 'project-category','field' => 'slug'
        ),));
    $the_query = new WP_Query( $cat_terms); ?>

<div id="ExampleCarouselID" class="carousel slide" data-ride="carousel" data-interval="7000">
    <ol class="carousel-indicators">
        <!-- Start Carousel Indicator Loop -->
        
        <?PHP 
        
        if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <li data-target="#ExampleCarouselID" data-slide-to="<?PHP echo $the_query->current_post; ?>" class="<?PHP if ( $the_query->current_post == 0 ) : ?>active<?PHP endif; ?>"></li>
        <?PHP endwhile; endif; ?>
    </ol>
<?PHP rewind_posts(); ?>

<div class="carousel-inner"> 
        <?PHP if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
              $thumbnail_id   = get_post_thumbnail_id();
              $thumbnail_url  = wp_get_attachment_image_src( $thumbnail_id,'full',true );
              $thumbnail_Meta = get_post_meta( $thumbnail_id,'_wp_attatchment_image_alt',true );
        ?>

                    <div class="carousel-item <?PHP if ( $the_query->current_post == 0 ) : ?>active<?PHP endif; ?> ">
                                <?PHP if ( has_post_thumbnail() ) : ?>
                                    <a href="<?PHP the_permalink(); ?>" title="<?PHP the_title_attribute(); ?>">
                                    <?PHP the_post_thumbnail('full'); ?>
                                    </a>
                                <?PHP endif; ?>

                                <div class="container">
                                    <div class="carousel-caption">
                                        <h1><?PHP the_title(); ?></h1>
                                    </div>
                                </div>
                            </div><!-- /.carousel-item -->
        <!-- end second loop -->
    <?PHP endwhile; endif; ?>
    </div><!-- /.carousel-inner -->

我错过了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)