I’m using this code to get featured image from post. This is my whole code every thing else is working rather than the image i’m trying to display featured image also the posttype i’m using is custom post type.
Can anyone tell what I’m doing wrong?
add_shortcode('get-video-post-type','videos_cpt');
function videos_cpt(){
$args = array(
'post_type' => 'Videos',
'post_status'=>'publish',
);
$result = new WP_Query($args);
if ($result -> have_posts()){
while($result -> have_posts()){
$result -> the_post();
?>
<div id="show-all-post" class="posts-carousel">
<div class="item" id="video-box">
<div class="left-img"><img class="post-image" src="<?php echo get_the_post_thumbnail( get_the_ID() , 'full' ); ?>" alt="image"></div>
<div class="right-content">
<h1 style="color:black;"><?php the_title();?></h1>
<p style="color:black;"><?php echo substr(get_the_excerpt(), 0,50); ?>....</p>
<a href="<?php the_permalink();?>">Read More</a>
</div>
</div>
</div>
<?php
}
}
wp_reset_postdata();
}
3
Answers
You can Try this one:
Can you try this: