Saturday, July 5, 2014

Add future image to wordpress post?

Here i am  going to discuss about how can we add feature image selection in wordpress post or pages

For Feature image  support we need to add following in your template function.php
add_theme_support( 'post-thumbnails' );

This will enable to add feature image to you post and page screen. we will list the post those only have feature image like below

query_posts( array('posts_per_page' => 5, 'meta_key' => '_thumbnail_id','post_type'=> 'post') );
if (have_posts()) :
    while (have_posts()) : the_post();
    $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'slider');
    endwhile;
endif;

using above you can get the image url and enjoy what ever you want.

No comments:

Post a Comment