Last active
January 2, 2016 12:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.testimonials { | |
.testimonial { | |
display: none; | |
&:first-child { | |
display: inline; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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