Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter imlost

    (@imlost)

    The first echo ($postid) was causing the issue
    after commenting that out everything is working great!

    Simon thanks for all your help!

    Thread Starter imlost

    (@imlost)

    With the new code I am much closer to the desired result as the “static page” I am using to shows display posts (wp-admin => settings => reading => Posts page) is returning the default value. But I am now receiving an error in the returned value on the other static pages throughout the site.

    In the returned value on the header function I am now receiving a two digit value prefixing the custom field value. below is the result of both the new and old header code as you will note “23” prefixed on the header string:

    #header{
    		background: #fff url("http://mysite.com/wp-content/uploads/2011/01/23Reverse-00.jpg") top center no-repeat;
    }
    
    #header-old{
    		background: #fff url("http://mysite.com/wp-content/uploads/2011/01/Reverse-00.jpg") top center no-repeat;
    }

    I am only 7 days into using WP so I do not know if my guess is correct but I would assume that the two digit prefix is the page id as it is different on each page?

    Thread Starter imlost

    (@imlost)

    What is happening is the following…

    In the header I am using a custom field to help populate a url string that returns the page banner based on the topic of the page and what is entered into a custom field “BannerIcon”.

    ‘#header{
    background: #fff url(“http://myweb.com/wp-content/uploads/2011/01/<?php global $wp_query;$postid = $wp_query->post->ID;echo get_post_meta($postid, ‘BannerIcon’, true); ?>”) top center no-repeat;
    }’

    this builds:

    ‘#header{
    background: #fff url(“http://myweb.com/wp-content/uploads/2011/01/Banner-Runner.jpg”) top center no-repeat;
    }’

    This works for all pages except “Corporate News” which is the page that holds my blog Loop. in that case it returns:

    ‘#header{
    background: #fff url(“http://myweb.com/wp-content/uploads/2011/01/”) top center no-repeat;
    }’

    The above is leaving the banner area blank because the image name is absent which is telling me that no value is returned for my custom field “BannerIcon”

    I do not know why all the other pages would work correctly and this one is not unless this has to do with the blog post loop being on the page.

    So my questions are:

    Why is this happening?
    Is there a quick snipet of code I can use that in the event “BannerIcon” has no value or returns nothing defaults to “newImage.png”? Basically an If, then, else statement.

    ~NC

Viewing 3 replies - 1 through 3 (of 3 total)