Skip to content

Instantly share code, notes, and snippets.

@ebinnion
Last active January 2, 2016 12:19
Show Gist options
  • Save ebinnion/8302584 to your computer and use it in GitHub Desktop.
Save ebinnion/8302584 to your computer and use it in GitHub Desktop.
This gist demonstrates how to build a basic testimonials fade in and fade out.
jQuery(document).ready(function($){
var testimonials = $('aside .testimonials .testimonial');
var current = 0;
function slide(){
intv = setInterval(function() {
$(testimonials[current]).fadeOut('slow', function(){
if( typeof testimonials[current+1] != 'undefined') {
current += 1;
} else {
current = 0;
}
$(testimonials[current]).fadeIn('slow');
});
}, 5000 );
}
slide();
});
.testimonials {
.testimonial {
display: none;
&:first-child {
display: inline;
}
}
}
<div class="testimonials">
<?php
$testimonials = new WP_Query(
array(
'post_type' => 'testimonials',
'posts_per_page' => -1
)
);
if ( $testimonials->have_posts() ):
while( $testimonials->have_posts() ): $testimonials->the_post(); ?>
<div class="testimonial">
<?php
$meta = get_post_meta($post->ID);
echo '<p class="test">'.get_the_content().'</p>';
echo '<p class="meta">'.get_the_title().'<br>'.$meta['_testimonial_title'][0].'<br>'.$meta['_testimonial_company'][0].'</p>';?>
</div>
<?php endwhile;
endif;
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment