WordPress.org

Forums

WP Nivo Slider
Post Title and Description instead of Image Title (10 posts)

  1. macuache
    Member
    Posted 4 years ago #

    What to add and where to make caption show Post title and post description (post text) in the slide caption instead of Image title.

    Please give a clear tutorial or procedure to that particular plugin.

    http://wordpress.org/extend/plugins/wp-nivo-slider/

  2. skyer2000
    Member
    Posted 3 years ago #

    Find the wp-nivo-slider.php file (/wp-content/plugins/wp-nivo-slider/wp-nivo-slider.php) then at line 89 find the #slider div. Replace that div with:

    <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()) : ?>
    
    	<?php
    		// get the thumbnail information
    		$thumbnail_id = get_post_thumbnail_id();
    		$thumbnail_object = get_post($thumbnail_id);
    	?>	
    
    	<img src="<?php echo $thumbnail_object->guid; ?>" width="<?php echo get_option('wpns_width'); ?>" height="<?php echo get_option('wpns_height'); ?>" title="<?php echo strip_tags(get_the_content()); ?>" />
    
    	<?php endif ?>
    	<?php endwhile; endif;?>
    	<?php wp_reset_query();?>
    </div>
  3. skyer2000
    Member
    Posted 3 years ago #

    That code can be expanded to allow HTML captions, however I did not need that for my project!

    I believe this plugin should include this code by default, it makes much more sense to easily edit the caption in the post editor.

    Also, another suggestion for the plugin author: the CSS should not be imbedded directly into the plugin. Maybe make it an option to use your own? I copied the CSS from your plugin into my own external stylesheet to make changes.

  4. AidenVennis
    Member
    Posted 3 years ago #

    Is there a way to enable HTML links in the caption? When I remove strip tags from the code it just doesn't work. Any idea how to fix that?

  5. AidenVennis
    Member
    Posted 3 years ago #

    Ah fixed it!

    <?php query_posts( 'cat='.$category.'&posts_per_page=$n_slices' ); if( have_posts() ) : while( have_posts() ) : the_post(); ?>
    	<?php if(has_post_thumbnail()) : ?>
    
    	<?php
    		// get the thumbnail information
    		$thumbnail_id = get_post_thumbnail_id();
    		$thumbnail_object = get_post($thumbnail_id);
    	?>	
    
    	<img src="<?php echo $thumbnail_object->guid; ?>" width="<?php echo get_option('wpns_width'); ?>" height="<?php print get_option('wpns_height'); ?>" title="<?php $content = get_the_content(); echo htmlentities($content,ENT_QUOTES); ?>" />
    
    	<?php endif ?>
    	<?php endwhile; endif;?>
    	<?php wp_reset_query();?>
    </div>

    Problem was that you can't use double quotes in the title field becuase it wil break up that piece of code. When coding HTML you use single quotes for that, but if you add a link in WordPress it uses double quotes of course. So I added a piece of PHP code that changes the double quotes to single quotes and removed the striptags piece :)

  6. blitz999
    Member
    Posted 3 years ago #

    Is this for an older version of the plugin?

    I think I have the same issue as the original one. I've used featured images from a nextgen gallery. The caption overlay shows the gallery title. Ideally, I'd like it to show the post title and not the gallery name.

    I tried changing line 215:
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    to this:
    <a href="<?php the_permalink(); ?>" title="<?php single_post_title(); ?>">

    Which doesn't make any difference!

    Anyone know how to make the caption as the post title?

  7. sweetie25
    Member
    Posted 3 years ago #

    @skyer2000
    Will you provide the code for expanding it to allow HTML captions? I'd love to see if it works. The previous code you provided is the only solution that has worked, Though I edited it some.

    <a href="<?php the_permalink(); ?>"><img src="<?php echo $thumbnail_object->guid; ?>" width="<?php echo get_option('wpns_width'); ?>" height="<?php echo get_option('wpns_height'); ?>" title="<?php the_title_attribute(); ?> <?php echo strip_tags(get_the_content()); ?>" /></a>

    Been trying to figure out how to make the title / php the_title_attribute() AND the more... / php echo strip_tags(get_the_content()) also link to the post.

    Thanks!

  8. skyer2000
    Member
    Posted 3 years ago #

    @sweetie25

    The latest version of Nivo Slider supports HTML captions natively. This plugin is pretty outdated, I recommend looking at one of the newer Nivo (or the official: http://nivo.dev7studios.com/) Slider plugins.

  9. sweetie25
    Member
    Posted 3 years ago #

    @skyer2000

    Thanks!

  10. Vilkdagiss
    Member
    Posted 3 years ago #

    Hello, I used skyer2000 and sweetie25 offered code, but I can only get either a description or a title, but never both. Looks like it depends on title="". Tried many options, but nothing works the way I need.
    Please help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Nivo Slider
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic