Skip to content

Instantly share code, notes, and snippets.

@aristath
Created September 17, 2012 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aristath/3736642 to your computer and use it in GitHub Desktop.
Save aristath/3736642 to your computer and use it in GitHub Desktop.
<?php
function single_product_images_slider($echo, $id){
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $id,
));
if ( $attachments ) {
$content = '<div class="single-product-image-slider">';
$content .= '<div class="flexslider">';
$content .= '<ul class="slides">';
foreach ( $attachments as $attachment ) {
$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
$img_attributes = wp_get_attachment_image_src($attachment->ID, 'full' );
$img = '<img itemprop="image" src="' . $img_attributes[0] . '" />';
$content .= '<li class="' . $class . ' data-design-thumbnail">' . $img . '</li>';
}
$content .= '</ul></div></div>';
$content .= '<script type="text/javascript" charset="utf-8">
jQuery(window).load(function() {
jQuery(".single-product-image-slider .flexslider").flexslider({
slideshowSpeed: 7000,
animation: "slide"
});
});
</script>';
$content .= '<div class="region-divider"></div>';
}
if ($echo)
echo $content;
else
return $content;
}
function product_with_slider($id){
$post = get_post($product_id);
$content .= single_product_images_slider(false, $id);
$content .= '<div itemprop="description" class="mp_product_content">';
$content .= apply_filters('the_content', $post->post_content);
$content .= '</div>';
$content .= '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="mp_product_meta">';
$content .= mp_product_price(false, $id);
$content .= mp_buy_button(false, 'single', $id);
$content .= '</div>';
echo $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment