Is there is a way to get c开发者_如何学运维urrent slide "title" of a Nivo Slider and display it in another div?
Starting at line 209 in wp-nivo-slider.php
Change:
<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>
To:
<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>
This will put the title in the upper left hand corner of the image with a semi-transparent background.
精彩评论