21
2011
How to set post first image as featured image automatically
From wordpress 3.0 version wordpress launched the feature called featured image. Many new wordpress themes are compatible with new wordpress version. So using or choosing the image as featured image for post is another manual work we need to do.
Many old wordpress website holder or blogger is having issue with this functionality. What they want is when they create the post they haven’t set the featured image, but they would like the featured image to default to the image that has been included in the post.
Some wordpress always use the first image as featured image but old post was not updated with featured image. They need to do manual work to set the featured image. I also faced same issue.
After doing some R&D I found the solution. If you want to set the your posts first image as featured image then use my following code.
For using the code you need to open your mysql database command prompt or phpmysqladmin program and select your wordpress database and execute the following query in that.
INSERT INTO `wp_postmeta` (`meta_value`, `meta_key`, `post_id`) SELECT DISTINCT(ID), post_type , post_parent from wp_posts where post_type = ‘attachment’ and post_parent != 0 AND post_status = ‘inherit’;
update wp_postmeta set meta_key = ‘_thumbnail_id’ where meta_key =’attachment’;
Using above sql query you will be able to set the featured image to your old and new post from post content. If you are having any issues with using this sql then write to me.
<a href=”http://wordpressapi.com/2010/12/20/set-post-image-featured-image-automatically/”>How to set post first image as featured image automatically</a>
Leave a comment
Sponsors
Tag Cloud
Recent Comments
- Ptxfgmac on Sử dụng CURL để update facebook, login wordpress và nhiều thứ khác
- Uysmbyoh on Sử dụng CURL để update facebook, login wordpress và nhiều thứ khác
- Fmbktiom on Sử dụng CURL để update facebook, login wordpress và nhiều thứ khác
- the pilatesbiz on The Web Developer’s SEO Cheat Sheet
- Albert on Sử dụng các thuộc tính CSS3 cho IE với PIE
- Christian Louboutin Men Shoes on position: fixed in IE
- Boby Banh on 11 bài học để kiếm đựoc $100 đầu tiên từ việc viết Blog
- xu ly anh on 11 bài học để kiếm đựoc $100 đầu tiên từ việc viết Blog
An article by












