Shortcode
// Add Shortcode
function adele_slider_shortcode() {
$result = '';
$include_javascript = plugin_dir_url( __FILE__ ) . 'assets/slick.min.js';
$include_css = plugin_dir_url( __FILE__ ) . 'assets/slick.min.css';
$include_css_theme = plugin_dir_url( __FILE__ ) . 'assets/slick-theme.css';
$result .= '<link rel="stylesheet" href="' . $include_css . '" />';
$result .= '<link rel="stylesheet" href="' . $include_css_theme . '" />';
$result .= '<script src="' . $include_javascript . '"></script>';
$result .= '<section class="regular slider">';
// WP_Query arguments
$args = array(
'post_type' => array( 'adele_front_slider' ),
'post_status' => array( 'publish' ),
'nopaging' => false,
'posts_per_page' => '50',
);
// The Query
$adele_custom_query = new WP_Query( $args );
// The Loop
if ( $adele_custom_query->have_posts() ) {
while ( $adele_custom_query->have_posts() ) {
$adele_custom_query->the_post();
$result .= '<div>';
$result .= get_the_post_thumbnail( null, 'full' );
$result .= '</div>';
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
$result .= '</section>';
$result .= "<script type='text/javascript'>jQuery(document).on('ready', function() {";
$result .= 'jQuery(".regular").slick({ dots: true, infinite: true, slidesToShow: 3, slidesToScroll: 3 });';
$result .= "});</script>";
return $result;
}
add_shortcode( 'adele_slider_shortcode', 'adele_slider_shortcode' );