Forums

Shoe custom field data from parent pagein child page (3 posts)

  1. clevercleaver
    Member
    Posted 2 years ago #

    This has probably already been done, or is so easy that I can't see the answer. I'm trying to get the data from the custom field in my parent pages (the data is an image url) to show up in my child pages (image acts as a header). I've tried a couple of different ways, but I wonder if this why this doesn't work:

    <img src="<?php echo get_post_meta($parent->ID, "headerimage", true);?>">

    Doesn't seem to be enough code there...how would it pull the parent id? Help is appreciated!!

  2. doc4
    Member
    Posted 2 years ago #

    clevercleaver,

    <img src="<?php bloginfo('url'); ?>/wp-content/uploads/<?php echo get_post_meta($post->ID, 'headerimage', $single=true) ?>">

    Try the above code then in the custom field only enter the file name without the extra path to the file. This will save a little time. Here is an example of what to type in the custom field: "myImage.jpg" (without the quotes)

  3. clevercleaver
    Member
    Posted 2 years ago #

    Hi Doc-

    This works fine for an image in the custom field for the child page itself. Problem is, it doesn't pull the custom field data that is in the child page's parent page.

    We're getting closer, though....

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.