Created
October 15, 2017 02:55
-
-
Save Galibri/2df53a3e6e02ecf69f845d66a924bd39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function stock_carousel_post($atts) { | |
extract( shortcode_atts( array( | |
'count' => -1 , | |
'type' => 'page', | |
'custom_css' => '', | |
), $atts) ); | |
$q = new WP_Query( | |
array( | |
'posts_per_page' => $count, | |
'post_type' => 'post', | |
) | |
); | |
$list = '<div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> | |
<div class="carousel-inner"> | |
'; | |
while($q->have_posts()) : $q->the_post(); | |
$post_count = 0; | |
$idd = get_the_ID(); | |
$post_content = get_the_excerpt(); | |
$list .= '<div class="carousel-item ' . if($post_count <1){ echo 'active ' } . ' carouselstyle" > | |
<div class="carousel-caption d-none d-md-block" > | |
<h3>'.get_the_title().'</h3><p>'.get_the_content().'</p> | |
</div> | |
'; | |
$post_count++; | |
endwhile; | |
$list.= ' </div> | |
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev"> | |
<span class="carousel-control-prev-icon" aria-hidden="true"></span> | |
<span class="sr-only">Previous</span> | |
</a> | |
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next"> | |
<span class="carousel-control-next-icon" aria-hidden="true"></span> | |
<span class="sr-only">Next</span> | |
</a> | |
</div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('cowse', 'stock_carousel_post'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment