Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

iam making a comic site like 9gag the front end upload page contains title upload image tags NSFW [checkbox] if every thing is normal the image become featured image of the post , i want the NSFW option to work , so if the uploader click the check box value (yes) will stored in costume filed called NFSWEG, so in the loop page iam showing the thumbnail by this code

<?php
   if(has_post_thumbnail())  {
    the_post_thumbnail(array(400,400, true),
    array("class" => "aligncenter featured_image")
      ); } ?>

iwant to replace the thumbanil with another image if the post have the value yes in the costume files your code worked perfectly now i want to implant it in this can you help me again i tried really but the is always an error idont know why

thanks that was enough

share|improve this question
    
What is NSFW? And, please, use proper lower/upper case in your text, see: meta.stackoverflow.com/a/47/185667 –  brasofilo Jan 21 '13 at 1:54
2  
I guess Not Safe For Work since we're talking about images here. –  RRikesh Jan 21 '13 at 4:50
add comment

1 Answer

get_post_meta is your friend:

if ( has_post_thumbnail() )  {
    if ( 'yes' == get_post_meta( $post->ID, 'NFSWEG', true ) ) {
        echo '<img src="YOUR-IMAGE-HERE">';
    } else {
        the_post_thumbnail(
            array( 400, 400, true ), 
            array( "class" => "aligncenter featured_image" )
            ); 
    }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.