Support » Fixing WordPress » Custom field image won’t appear on child page

  • plinth

    (@plinth)


    I’ve got a section of the sidebar that displays an image based on a custom field called “sidebar_image”. This works on all of my site pages and I can even duplicate the same image on several pages. But when I try to add the image “events_right.jpg” on a parent page, it won’t display on an of the child pages.

    Here’s my code for displaying the custom field:
    <img src="/wp-content/uploads/<?php $values = get_post_custom_values("sidebar_image"); echo $values[0]; ?>" alt="" />

    Any help appreciated.

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

    (@davidandre)

    Hi plinth!

    Do you have the same template page.php for the parent-pages and for the child-pages?

    if yes, do you have the custom field set up in the same way?

    Thread Starter plinth

    (@plinth)

    No, the parent and child pages have different page templates, but the custom field is inside sidebar.php so I wouldn’t have thought it would make a difference?

    davidandre

    (@davidandre)

    No, it shouldn t be a problem if you are using” get_sidebar “in both templates…

    have you set up the custom field in the same way?put your code in the forum ,i am sure somebody will find out..
    if i can help i ll do my best but i am not an expert so just trying..

    just one more question ,where did you put the code for displaying the custon field?inthe sidebar??
    If it is a page.php and not single.php i would not called the get_sidebar and put a div=”sidebar” and put the cade i need inside with the custom field… just copy this div in the code of the templates of your childpages and i think it should work even if there might be a better or more professional solution..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom field image won’t appear on child page’ is closed to new replies.