• Resolved geezerd

    (@geezerd)


    I’m using this to show a div that stretches the whole window, showing a fully stretched image:

    <?php $bg = get_post_meta($post->ID, bg, true);
    if($bg){ ?>
    <div id="page-background"><img src="<?php bloginfo( 'template_directory' ); ?>/images/<?php echo get_post_meta($post->ID, bg, true); ?>" alt="" width="100%" height="100%" /></div>
    <?php }else{ ?>
    <?php } ?>

    Works great, but it if the first (and only first) post on the blog page has that custom field, the whole blog page gets the custom field.
    Anyone know how to remedy this?
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter geezerd

    (@geezerd)

    Just so it’s clear:
    The ‘if’ statement has the custom field meta data with the containing div holding the image, and the ‘else’ statement is empty. If the top most post on the blog page has the custom field set in it, it shows the image on the blog page. If any other post other than the top most has the custom field, it’s fine, it doesn’t add the image the the blog page.

    Thread Starter geezerd

    (@geezerd)

    Wasn’t in the loop. And can’t be, so won’t work. Needs to be in a custom header.php file for just pages and single posts.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field in post is showing up on the blog page’ is closed to new replies.