No default photo in post.

Discussion in 'ClassiCraft WordPress Theme' started by themotorcycledude, Aug 6, 2013.

Thread Status:
Not open for further replies.
  1. themotorcycledude

    themotorcycledude Member

    Joined:
    Jul 11, 2013
    Messages:
    83
    Likes Received:
    0
    Hi,

    I posted an ad without any photos and noticed that there is no default photo or any placeholder in the ad detail page. It doesn't look very nice. Is there any way to get a default image in there?

    Screen shot 2013-08-05 at 8.43.59 PM.png


    Thanks!
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Hello,

    Go to single-ad.php present in your theme directory and replace current code

    Code:
          <?php
                                                        $cc_custom_meta = cc_get_custom_field();
                                                        foreach ($cc_custom_meta as $field) {
                                                            if ($field['type'] == 'image_uploader' && get_post_meta($post->ID, $field['htmlvar_name'], true) != '') {
                                                                ?>
                                                                <li> <img src="<?php echo get_post_meta($post->ID, $field['htmlvar_name'], true); ?>" /> </li>                                                 
                                                                <?php
                                                            }
                                                        }
                                                        ?>
    With code given below

    Code:
    <?php
                                                        $count = 0;
                                                        $cc_custom_meta = cc_get_custom_field();
                                                        foreach ($cc_custom_meta as $field) {
                                                            if ($field['type'] == 'image_uploader' && get_post_meta($post->ID, $field['htmlvar_name'], true) != '') {
                                                            $flag = true;
                                                                ?>
                                                                <li> <img src="<?php echo get_post_meta($post->ID, $field['htmlvar_name'], true); ?>" /> </li>                                                 
                                                                <?php
                                                            }elseif($field['type'] == 'image_uploader' && get_post_meta($post->ID, $field['htmlvar_name'], true) == ''){
                                                            if($count == 1){
                                                                $default_img = get_template_directory_uri().'/images/temp/sample1.png';
                                                            print "<li><img src='".$default_img."'/></li>";
                                                            }
                                                            ?>
                                                            <?php
                                                            }
                                                            $count++;
                                                        }
                                                        ?>

    Sending image for reference

    2013-08-06_1716.png



    This will solve your issue.
     
  3. themotorcycledude

    themotorcycledude Member

    Joined:
    Jul 11, 2013
    Messages:
    83
    Likes Received:
    0
    That worked thanks!
     
Thread Status:
Not open for further replies.

Share This Page