Wordpress猫头鹰旋转木马添加空项目

时间:2017-11-25 08:11:30

标签: php wordpress owl-carousel

我的主题中有一个预安装小部件的问题(称为meteroite)。如果需要,完整的小部件代码在这里: https://codeshare.io/5Mbrne

这是显示我所有CPT员工项目的确切部分:

$employees = new WP_Query(array(
            'no_found_rows'     => true,
            'post_status'       => 'publish',
            'post_type'         => 'employees',
            'posts_per_page'    => $number,
            'employee-category' => $category
        ) );

        $type_class = '';
        if ( $type == 'Square' ) :
            $type_class = 'square';
        elseif ( $type == 'Round' ) :
            $type_class = 'round';
        endif;

        $data_autoplay = 'false';
        if ( $enable_autoplay == 'On' ) :
            $data_autoplay = intval($autoplay);
        endif;

        $data_pagination = 'false';
        if ( $pagination == 'Show' ) :
            $data_pagination = 'true';
        endif;

        $centered_class = '';
        if ( $center_content == 'Yes' ) :
            $centered_class = 'centered';
        endif;

        $animation_class = '';
        $animation_single = '';
        if ( $animation == 'Fade In' ) {
            $animation_class = 'fade-in';
        } elseif ( $animation == 'Fade In Up' ) {
            $animation_class = 'fade-in-up';
        } elseif ( $animation == 'Fade In Left' ) {
            $animation_class = 'fade-in-left';
        } elseif ( $animation == 'Fade In Right' ) {
            $animation_class = 'fade-in-right';
        } elseif ( $animation == 'Fade In One By One' ) {
            $animation_single = 'fade-in-single';
        } elseif ( $animation == 'Fade In Up One By One' ) {
            $animation_single = 'fade-in-up-single';
        }

        echo $args['before_widget'];

        if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; }

        if ( $employees->have_posts() && post_type_exists( 'employees' )  ) : ?>

        <div class="meteorite-team carousel owl-carousel <?php echo $centered_class . ' ' . $animation_class . $animation_single; ?>" data-items-large="<?php echo $itemsLarge; ?>" data-items-medium="<?php echo $itemsMedium; ?>" data-items-small="<?php echo $itemsSmall; ?>" data-autoplay="<?php echo $data_autoplay; ?>" data-pagination="<?php echo $data_pagination; ?>">
            <?php while ( $employees->have_posts() ) : $employees->the_post(); ?>
                <?php //Get the custom field values
                    $position       = get_post_meta( get_the_ID(), 'tt-position', true );
                    $socialOne      = get_post_meta( get_the_ID(), 'tt-socialOne', true );
                    $socialTwo      = get_post_meta( get_the_ID(), 'tt-socialTwo', true );
                    $socialThree    = get_post_meta( get_the_ID(), 'tt-socialThree', true );
                    $empMail        = get_post_meta( get_the_ID(), 'tt-mail', true );
                    $link           = get_post_meta( get_the_ID(), 'tt-custom-link', true );
                ?>
                <div class="team-item meteorite-item <?php echo $type_class; ?>">
                    <div class="team-inner">
                        <?php if ( has_post_thumbnail() ) : ?>
                        <div class="avatar">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <?php endif; ?>
                        <div class="team-content">
                            <div class="name">
                                <?php if ( $link == '' ) : ?>
                                    <?php the_title(); ?>
                                <?php else : ?>
                                    <a href="<?php echo esc_url( $link ); ?>"><?php the_title(); ?></a>
                                <?php endif; ?>
                            </div>
                            <div class="pos"><?php echo esc_html( $position ); ?></div>
                            <div class="excerpt">
                                <?php the_content(); ?>
                            </div>
                        </div>
                        <div class="team-social">
                            <ul class="team-social social-icons">
                                <?php if ( $socialOne != '' ) : ?>
                                    <li><a href="<?php echo esc_url( $socialOne ); ?>" target="_blank"></a></li>
                                <?php endif; ?>
                                <?php if ( $socialTwo != '' ) : ?>
                                    <li><a href="<?php echo esc_url( $socialTwo ); ?>" target="_blank"></a></li>
                                <?php endif; ?>
                                <?php if ( $socialThree != '' ) : ?>
                                    <li><a href="<?php echo esc_url( $socialThree ); ?>" target="_blank"></a></li>
                                <?php endif; ?>
                                <?php if ( $empMail != '' ) : ?>
                                    <li><a href="mailto:<?php echo sanitize_email( $empMail ); ?>"></a></li>
                                <?php endif; ?>
                            </ul>
                        </div>
                    </div>
                </div>
            <?php endwhile; ?>
        </div>

        <?php
        wp_reset_postdata(); ?>

问题描述: 我在CPT里面有3个项目(我们称之为:Joe / Harry / Adam)。没有别的,只有三个帖子。但是在显示时,owl carousel(因此负责旋转木马的脚本)会生成4个项目,这些项目来自最后一个 - &gt;是空的。因此,当他们交换/滚动项目时,我的页面浏览器非常消耗,而最后一个是空白的。你知道那是什么吗?

0 个答案:

没有答案