• Hi WordPressers ??

    I have a custom field property ‘BannerImage’ for my pages.

    When it’s not filled in, it should find the ‘BannerImage’ of its parent. Is this hard to do?

    Thx for keeping me posted ??

    Kind regards,
    Yannick

Viewing 3 replies - 1 through 3 (of 3 total)
  • In theory, yes.

    if( !get_post_meta($post_id, 'BannerImage', true) ) $custom_field = get_post_meta($post->parent, 'BannerImage', true);
    else $custom_field = get_post_meta($post_id, 'BannerImage', true);
    Thread Starter Norke

    (@norke)

    Oh esmi,

    Thank you!

    This is what I ended up with:

    if(!get_post_meta($post->ID, 'BannerImage', true)) {
    		$banner_image = get_post_meta($post->post_parent, 'BannerImage', true);
    	} else {
    		$banner_image = get_post_meta($post->ID, 'BannerImage', true);
    	}
    	echo '<img src="' . $banner_image . '" />';

    Thx again for the quick help!

    Glad I could help – even if I did get $post->parent wrong (I should have checked first). ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Field cascading system’ is closed to new replies.