Skip to content

Instantly share code, notes, and snippets.

@CotswoldPhoto
Last active February 5, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CotswoldPhoto/ffffeae2768274a81b20 to your computer and use it in GitHub Desktop.
Save CotswoldPhoto/ffffeae2768274a81b20 to your computer and use it in GitHub Desktop.
Modify WP Posts Carousel plugin to remove link from Featured Image
@teastudio
Copy link

try this

<?php
function my_wpc_disable_featured_image_link( $featured_image, $params ) {
    if ( $params['params']['show_featured_image'] === 'true' ) {
        $data_src = 'src="' . $params['image'] . '"';
        $image_class = null;

        if ($params['params']['lazy_load'] === 'true') {
            $data_src = 'data-src="' . $params['image'] . '" data-src-retina="' . $params['image']. '"';
            $image_class = 'class="owl-lazy"';
        }

        $featured_image = '<div class="wp-posts-carousel-image">';
            $featured_image.= '<img alt="' . $params['post']->post_title . '" style="max-width:' . $params['params']['image_width'] . '%;max-height:' . $params['params']['image_height'] . '%" ' . $data_src . $image_class . '>';
        $featured_image.= '</div>';

        return $featured_image;
    }
}
add_filter('wpc_item_featured_image', 'my_wpc_disable_featured_image_link', 1, 2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment