• Hi.
    How to use if when I have custom field, like this..

    In this side I have this:

    <div class="thumbnail-forare">
    					<?php if ( has_post_thumbnail() ) {
    					   // Om inl?gget har en thumbnail
    					}
    					else {
    					   // Om inl?gget inte har en nagel
    					}
    					?>
    					<?php the_post_thumbnail(); ?>
               <?php if ( '' != get_the_post_thumbnail() ) {
        // some code
    } else {
        // some code
    		echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/thumbnails/default-1.jpg" />';
    }
    ?>
    </div> <!-- thumbnail -->

    Works perfect. But when I will have the same in single.php (in this side) I need to use custom field instead of thumbnails but then I don’t get it to work. Pleas help, I would really appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Are you using a plugin for the custom field?

    Thread Starter driftmagazine

    (@driftmagazine)

    I have “Custom Post Type UI” but I don’t think I use it. When I type a custom field I use the one built-in in WordPress.

    Thread Starter driftmagazine

    (@driftmagazine)

    I wold like something like this to work

    <?php 
    
    if 
    
    <?php echo get_post_meta($post->ID, "profilfoto", true); ?>} 
    
    else {
    
    <img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/thumbnails/default-1.jpg" />
    }
    
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘if custom field img’ is closed to new replies.