Add Play Icon on thumbnail overlay for video post types

admin2025-01-08  7

i was thinking if there was anyway to add a okay icon overlay for video post types, i already came up with a code that allows me set up a default thumbnail if post has no thumb, sample code below.

<div class="img-responsive"> <?php if ( has_post_thumbnail() ) : ?>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('big-grid-one-image'); ?></a>
<?php else : ?>
    <img src=" <?php echo get_template_directory_uri (); ?>/img/no-thumb/acardio-548px-450px.png" />


<?php endif; ?></div>

i was thinking if there was anyway to add a okay icon overlay for video post types, i already came up with a code that allows me set up a default thumbnail if post has no thumb, sample code below.

<div class="img-responsive"> <?php if ( has_post_thumbnail() ) : ?>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('big-grid-one-image'); ?></a>
<?php else : ?>
    <img src=" <?php echo get_template_directory_uri (); ?>/img/no-thumb/acardio-548px-450px.png" />


<?php endif; ?></div>
Share Improve this question asked Mar 16, 2017 at 22:42 Kazem NocktrineKazem Nocktrine 75 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Not sure where you are running your code but the below will get the post type of video if it is set I think that Wordpress returns false if there is no post type.

// This will get the post id and then test for the format type
global $post;
$post_id = $post->ID;
$post_format = get_post_format($post_id);

// If your post type is a video add the code inside
if($post_format == 'video'){
    //your code
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736268796a1303.html

最新回复(0)