Wordpress bootstrap slider/carousel without extra plugin 30.10.18
';
endif;
return join("\n",$html);
}
3.
add this function to your functions.php theme file:
function slider_code($atts = [], $content = null, $tag = '')
{
$a = array_change_key_case((array)$atts, CASE_LOWER);
$slides = [];
$args = ['category_name' => $a['category'], 'nopaging'=>true, 'posts_per_page'=>5,'orderby'=>'title','order'=>'asc'];
$slider_query = new WP_Query($args);
if($slider_query->have_posts()):
while($slider_query->have_posts())
{
$slider_query->the_post();
if(has_post_thumbnail()):
$a2 = [];
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
$thumb_url = $thumb_url_array[0];
$a2['title'] = get_the_title();
$a2['excerpt'] = get_the_excerpt();
$a2['img'] = $thumb_url;
$slides[] = $a2;
endif;
}
endif;
wp_reset_postdata();
return render_slider($slides);
}
add_shortcode('slider_code', 'slider_code');
https://www.lyrathemes.com/bootstrap-carousel-tutorial/