How to Upload image and show in page in wordpress customPostType?

Iam new in wordpress Theme development ,I have made a custom Post for image upload . The code in functions.php is here:

register_post_type(‘features1’, array(
‘labels’ => array(
‘name’ => __(‘Features1’),
‘singular_name’ => __(‘features1’)
),

‘public’ => true,
‘has_archive’ => true,
‘supports’ => array(‘thumbnail’)
));

The code for index.php Where i want to show image is :

<div class=”row”>
<?php query_posts(array(‘post_type’=>’features1′,’posts_per_page’=>’1’));
while(have_posts()):the_post();
?>

<div class=”col-md-5″ align=”center”>
<?php if(has_post_thumbnail()):

$image = wp_get_image_attachment_src(get_post_thumbnail_id(), ‘large’);
?>
<img src=”<?php echo $image; ?>” class=”img-responsive”>
<?php endif; ?>

</div>
<?php endwhile; ?>

But This code Doesnt work for me . When i didnt upload image my site runs properly ,But when i upload image This features page shown blank …
Could AnyOne please Send me Code That works properly for me??

Read more here:: How to Upload image and show in page in wordpress customPostType?

Leave a Reply

Your email address will not be published. Required fields are marked *