Skip to content

Instantly share code, notes, and snippets.

@senlin
Created August 18, 2012 06:44
Show Gist options
  • Save senlin/3384967 to your computer and use it in GitHub Desktop.
Save senlin/3384967 to your computer and use it in GitHub Desktop.
sample code to implement ContentFlow.js in WordPress
<?php
// the following will be part of your loop.
?>
<div class="ContentFlow">
<div class="flow">
<?php
$asliders = query_posts('post_type=artist&posts_per_page=-1');
if ($asliders) {
foreach ($asliders as $aslider) {
// my original code included a checkbox custom metabox "_artist_slider", the code below calls these metadat and checks whether this box has been ticked ("on"). If your site doesn't use any metaboxes to condtionally show the post in the slider, then you need to delete the "if ($meta == 'on')" condition.
$meta = get_post_meta($aslider->ID, '_artist_slider', true);
if ($meta == 'on') {
echo '<div class="item" href="' . get_permalink($aslider->ID) . '">';
echo get_the_post_thumbnail ($aslider->ID, array ( 200,100 ), array( 'class' => 'content' ) );
echo '<div class="caption">';
echo get_the_title($aslider->ID);
echo '</div>';
echo '</div>';
}
}
}
?>
</div><!--.flow-->
<div class="scrollbar"><div class="slider"><div class="position"></div></div></div>
</div><!--.ContentFlow-->
<?php
// the following will have to be added to your header; in my case I used the white addon, so I added load=white
?>
<script language="JavaScript" type="text/javascript" src="<?php bloginfo('template_directory'); ?>/scripts/contentflow.js" load="white"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment