简体   繁体   中英

Wordpress PHP duplicating thumb

I am not very skilled in php, but I believe something in this section is causing my Fancybox images to duplicate.

When Fancybox opens, the user can use the Next and Prev links, but each image is duplicated twice. I have tested by replacing fancybox with another lightbox and the problem still persists.

Does anyone see the issue in this, have any ideas how to fix or hack it?

<?php
    $work_count = 0;
    $recent_work_args = apply_filters( 'evolution_recent_work_args', array(
        'showposts' => (int) get_option('evolution_posts_work_num'),
        'category__not_in' => (array) get_option('evolution_exlcats_work')
    ) );
    $recent_work_query = new WP_Query( $recent_work_args );
    while ( $recent_work_query->have_posts() ) : $recent_work_query->the_post();
        ++$work_count;
        $width = apply_filters( 'evolution_home_work_width', 203 );
        $height = apply_filters( 'evolution_home_work_height', 203 );
        $titletext = get_the_title();
        $thumbnail = get_thumbnail($width,$height,'item-image',$titletext,$titletext,true,'Work');
        $thumb = $thumbnail["thumb"];
        $lightbox_title = ( $work_title = get_post_meta($post->ID, 'work_title',true) ) ? $work_title : $titletext;
        $work_description = ( $work_desc = get_post_meta($post->ID, 'work_description',true) ) ? $work_desc : truncate_post( 50, false );
?>
        <div class="r-work<?php if ( 0 == $work_count % 5 ) echo ' last'; ?>">
            <?php print_thumbnail($thumb, $thumbnail, $titletext, $width, $height, 'item-image'); ?>
            <span class="overlay"></span>
            <a href="<?php echo esc_url($thumbnail['fullpath']); ?>" class="zoom fancybox" title="<?php echo esc_attr( $lightbox_title ); ?>" rel="work_gallery"></a>
            <a href="<?php echo esc_url($thumbnail['fullpath']); ?>" class="zoom fancybox" title="<?php echo esc_attr( $lightbox_title ); ?>" rel="work_gallery"></a>
            <p><?php echo esc_html( $work_description ); ?></p>
        </div> <!-- end .r-work -->
<?php endwhile; wp_reset_postdata(); ?>

Well, for one, you're outputting two links to the thumbnail:

        <a href="<?php echo esc_url($thumbnail['fullpath']); ?>" class="zoom fancybox" title="<?php echo esc_attr( $lightbox_title ); ?>" rel="work_gallery"></a>
        <a href="<?php echo esc_url($thumbnail['fullpath']); ?>" class="zoom fancybox" title="<?php echo esc_attr( $lightbox_title ); ?>" rel="work_gallery"></a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM