Jump to content
Sign in to follow this  
strategicblend

Any image as thumbnail in posts

Recommended Posts

strategicblend

Is there a way for Platform Pro to utilize any image in the post as the thumbnail, if a featured image isn't designated?

Share this post


Link to post
Share on other sites
catrina

Do you want the post thumbnail to be set up using a means other than the featured image capability?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
strategicblend

I want it to pull from an image added to the post if a featured image isn't detected.

Share this post


Link to post
Share on other sites
cmunns

Would have to add a function to your child theme and include the function call in your template.postloop.php ` function main_image() { $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image&order=desc'); if($files) : $keys = array_reverse(array_keys($files)); $j=0; $num = $keys[$j]; $image=wp_get_attachment_image($num, 'large', true); $imagepieces = explode('"', $image); $imagepath = $imagepieces[1]; $main=wp_get_attachment_url($num); $template=get_template_directory(); $the_title=get_the_title(); print "$the_title"; endif; } //goes in template.postloop to call image <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { echo get_the_post_thumbnail(); } else { echo main_image(); } ?> `

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×