我使用的是 wordpress 主题 Pitch Pro,它有一个内置的 slider 。我的问题是有时 slider 会闪烁错误的图像一秒钟。我注意到它通常不会这样做,但只有当我从支持页面转到主页时才会这样做。我试过更改并设置顺序。更改幻灯片的最大数量,目前为 6,但似乎无法解决。
如果有人对修复有任何想法,该站点目前是 jrummy16.com/test。
不确定这是否与它有关,但我使用的服务器有问题并修复它 hostgator 告诉我添加 define( 'CONCATENATE_SCRIPTS', false );到我的 config.php 文件。它解决了这个问题,但我不记得在添加之前 slider 有这个问题。
我什至不知道如何开始解决这个问题。因此,我们将不胜感激任何帮助。
编辑 所有文件都在主题 Pitch Pro 中找到。
我打开了我的 home.php 文件,我在 slider 的顶部找到了它。
<?php
$slider_template = apply_filters('pitch_slider_template', array('slider', null));
get_template_part( $slider_template[0], $slider_template[1] );
?>
然后我在同一个文件夹中打开了 slider.php。它有这个代码,
<?php
$slides = new WP_Query(array(
'numberposts' => siteorigin_setting('slider_max_slides'),
'nopaging' => true,
'post_type' => 'slide',
'orderby' => 'menu_order',
'order' => 'ASC'
));
if($slides->have_posts()){
?>
<div id="slider">
<div class="container">
<div class="slides nivoSlider">
<?php while ($slides->have_posts()) : $slides->the_post(); if(has_post_thumbnail()) : ?>
<?php if(get_post_meta(get_the_ID(), 'slide_destination', true)) : $destination = get_post_meta(get_the_ID(), 'slide_destination', true) ?>
<?php echo '<a href="'.esc_url(get_permalink($destination)).'" title="'.esc_attr(get_the_title($destination)).'">' ?>
<?php elseif(get_post_meta(get_the_ID(), 'slide_destination_url', true)) : $destination = get_post_meta(get_the_ID(), 'slide_destination_url', true) ?>
<?php echo '<a href="'.esc_url($destination).'">' ?>
<?php endif; ?>
<?php echo get_the_post_thumbnail(get_the_ID(), 'slide') ?>
<?php if(!empty($destination)) echo '</a>' ?>
<?php endif; endwhile; ?>
</div>
<?php $slides->rewind_posts(); ?>
<div class="indicators-wrapper">
<ul class="indicators">
<?php while ($slides->have_posts()) : $slides->the_post(); if(has_post_thumbnail()) : ?>
<li class="indicator <?php if($slides->current_post == 0) echo 'active' ?> indicator-group-<?php echo $slides->post_count ?>">
<div class="indicator-container">
<div class="pointer"></div>
<h4><?php the_title() ?></h4>
<?php the_excerpt() ?>
</div>
</li>
<?php endif; endwhile; ?>
</ul>
</div>
</div>
</div>
<?php
wp_reset_postdata();
}
我不确定这是否有帮助,但我希望它有帮助。
最佳答案
我认为原因是在 slider 完全加载之前,页面将显示幻灯片列表中的最后一张图片,在您的情况下是这张图片:
<img width="705" height="344" src="http://jrummy16.com/test/wp-content/uploads/BA-slider.jpg" class="attachment-slide wp-post-image" alt="BA-slider">
这是一个similar problem并且它几乎没有您也可以使用的解决方案。
更新:
我找到了这个 article这建议修改您的 CSS。我会在此处粘贴代码,但文章使用图像来显示 CSS 代码:)
关于html - 图像 slider 首先闪烁错误的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16312530/