-
Notifications
You must be signed in to change notification settings - Fork 32
Flexslider and Dynamic Featured Images
Here is the code I used in my block theme.
<?php /**
* Title: Flexslider
* Slug: yourthemenamehere/flexslider
* Inserter: no
* Categories: hidden
* last edited: 08-15-2023
**/
$postid = url_to_postid($_SERVER['REQUEST_URI']);
$imgs = '';
if( has_post_thumbnail($postid) ) {
$imgs = '<li><img src="' . get_the_post_thumbnail_url($postid) . '" /></li>';
}
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$images = $dynamic_featured_image->get_featured_images( $postid );
foreach( $images as $image ) {
$imgs .= '<li><img src="'.$image['full'].'" /></li>';
}
if( !empty( $imgs ) ) { ?>
<div class="flexslider">
<ul class="slides">
<?php echo $imgs; ?>
</ul>
</div>
<div id="carousel" class="flexslider">
<ul class="slides">
<?php echo $imgs; ?>
</ul>
</div>
<?php }
}
NOTE: see https://woocommerce.com/flexslider/ to load the proper CSS and JS files as well as necessary JS code snippet.