• Resolved vidar42

    (@vidar42)


    Is there a way with the widget to only have a certain amount of characters of the testimonial display with a clickable link to read more on that specific testimonial?

    As it stands the widget shows the entire testimonial (randomized) and if it is a long testimonial, it is quite unsightly on the page.

    http://wordpress.org/plugins/clean-testimonials/

Viewing 1 replies (of 1 total)
  • Plugin Author lukerollans

    (@hellolukerollansme)

    Hey Vidar,

    Currently there is no way to do this with any existing version of the plugin, however I will add it to the feature request list for a future version.

    In the meantime, you can use the following code to achieve this. Place it in the template in which you wish to display the shortened, random testimonial.

    <?php
    
    if( class_exists( 'WP_Testimonial' ) ) {
    
    	if( $testimonial = get_posts( array(
    
    		'post_type' => 'testimonial',
    		'posts_per_page' => 1,
    		'orderby' => 'rand'
    
    	) ) ) {
    
    		$testimonial = new WP_Testimonial( array_pop( $testimonial )->ID );
    		?>
    
    		<div class="single-testimonial">
    
    			<h3><?php echo $testimonial->post_title; ?></h3>
    
    			<blockquote>
    
    				<?php if( has_post_thumbnail( $testimonial->ID ) ): $image = wp_get_attachment_image_src( get_post_thumbnail_id( $testimonial->ID ), array( 200, 200 ) ); ?>
    				<img style="float: left; padding: 10px;" src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" />
    				<?php endif; ?>
    
    				<!-- Change the number below to specify how many characters you wish to display -->
    				<p>
    					<?php echo implode( chr(32), array_slice( explode( chr(32), $testimonial->post_content ), 0, 25 ) ); ?>
    				</p>
    				<p>
    					<a href="<?php echo get_permalink( $testimonial->ID ); ?>">Read More...</a>
    				</p>
    
    			</blockquote>
    
    			<h5>
    
    				<?php if( !empty( $testimonial->company ) ): ?>
    				<?php echo $testimonial->client; ?>,<br /><?php echo $testimonial->company; ?>
    				<?php else: ?>
    				<?php echo $testimonial->client; ?>
    				<?php endif; ?>
    
    				<?php if( testimonial_has_permission( $testimonial->ID ) ): ?>
    				<?php echo sprintf( '<br />Web: <a href="%s">%s</a>,<br />Email: <a href="mailto:%s">%s</a>', $testimonial->website, $testimonial->website, $testimonial->email, $testimonial->email ); ?>
    				<?php endif; ?>
    
    			</h5>
    
    			<br clear="all" />
    
    		</div>
    
    		<?php
    
    	}
    
    }
    
    ?>

    There is very little error checking, so tread lightly. In a future version, most likely the very next, I will include a more elegant option for this in the testimonial widget and also the shortcodes.

    If you’ve found the plugin useful, please consider taking a moment to rate it!

    Thank you very much for using Clean Testimonials.

Viewing 1 replies (of 1 total)

The topic ‘Short testimonial’ is closed to new replies.