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
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
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);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). :-)
You must log in to post.