Viewing 9 replies - 1 through 9 (of 9 total)
  • 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>

    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.

    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?

    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 ??

    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?

    @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!

    @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: https://nivo.dev7studios.com/) Slider plugins.

    @skyer2000

    Thanks!

    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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP Nivo Slider] Post Title and Description instead of Image Title’ is closed to new replies.