Created
November 7, 2016 07:33
-
-
Save captprice26/9b004534571540cf76513328d9a211cc to your computer and use it in GitHub Desktop.
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
// Horse Slider | |
function custom_shortcode() { | |
ob_start(); | |
$args = array( | |
'post_type' => 'product', | |
'meta_key' => '_featured', | |
'meta_value' => 'yes', | |
'posts' => -1 | |
); | |
$featured_query = new WP_Query( $args ); | |
if ($featured_query->have_posts()) : | |
echo '<div id="owl-example" class="owl-carousel">'; | |
while ($featured_query->have_posts()) : | |
$featured_query->the_post(); | |
$attachment_ids[0] = get_post_thumbnail_id( $product->id ); | |
//$attachment = wp_get_attachment_image_src($attachment_ids[0], 'thumbnail' ); | |
$newimage = get_the_post_thumbnail( $product->id, array(285, 285) ); | |
echo '<div class="item">'; | |
echo '<div class="horse-img"><a href="'. get_the_permalink() .'">' . $newimage . '</a></div>'; | |
echo '<h4>' . get_the_title() . '</h4>'; | |
$product_description = get_post($item['product_id'])->post_content; | |
$rest = substr( $product_description , 0, 200); | |
echo "<p>" . $rest . "...</p>"; | |
echo '<div class="read-more"><a href="' . get_the_permalink() . '"><img src="http://campwp.com/319/wp-content/uploads/2016/06/arrows_10.png" alt=""></a></div>'; | |
echo '</div>'; | |
endwhile; | |
echo '</div>'; | |
endif; | |
wp_reset_query(); | |
$out = ob_get_clean(); | |
return $out; | |
} | |
add_shortcode( 'HorseSlider', 'custom_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment