有没有办法获取 Nivo Slider 的当前幻灯片“标题”并将其显示在另一个 div 中?
问问题
1041 次
1 回答
1
从 wp-nivo-slider.php 的第 209 行开始
改变:
<div id="slider">
<?php
$category = get_option('wpns_category');
$n_slices = get_option('wpns_slices');
?>
<?php query_posts( 'cat='.$category.'&posts_per_page=$n_slices' ); if( have_posts() ) : while( have_posts() ) : the_post(); ?>
<?php if(has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif ?> <?php endwhile; endif;?> <?php wp_reset_query();?>
</div>
至:
<div id="slider" style="position:relative;">
query_posts( 'cat='.$category.'&posts_per_page=$n_slices' ); if( have_posts() ) : while( have_posts() ) : the_post(); ?>
<?php if(has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<div id="slider-title" style="position:absolute; background-image:rgba(0, 0, 0, .5); color:#fff!important; top:10px; left:5px; display:block;"><?php the_title(); ?></div>
<?php endif ?>
<?php endwhile; endif;?>
<?php wp_reset_query();?>
</div>
这会将标题放在图像的左上角,背景为半透明。
于 2011-04-26T23:15:15.657 回答