Forums

[resolved] Custom Field Outputting Array (3 posts)

  1. bjdavids649
    Member
    Posted 4 months ago #

    At my test site, I am trying to do different backgrounds for each page.

    I have a custom field called background-image with a url from the media area.

    I have the following just have the header call and before content:

    <style type=“text/css”>
    body {
    background-image: url('<?php echo get_post_meta($post->ID, ‘background-image‘, true); ?>');
    }
    </style>

    I don't see it's working and when I look at the code, it's outputs:

    <style type=“text/css”>
    body {
    background-image: url('Array')
    }
    </style>

    I cannot figure out what I'm doing wrong. I've tried Googling the answer but all information indicates I'm doing the right thing.

    Any ideas?

    Thanks,
    Barb

  2. bjdavids649
    Member
    Posted 4 months ago #

    I found out that my quotes around the background-image were of a difference character. I deleted them and retyped and now am seeing the right source, no more Array... except... I'm still not seeing my background? Ugh!

  3. bjdavids649
    Member
    Posted 4 months ago #

    I GOT IT!

    Changed the header.php file body line to:

    <body <?php body_class(); ?> style="background-image: url('<?php echo get_post_meta($post->ID, 'background-image', true); ?>');">

Reply

You must log in to post.

About this Topic