[resolved] Inherit Featured Image into Child Pages (4 posts)

  1. trevolutionary
    Posted 4 years ago #

    Is there any way to inherit a featured image from parent pages into all the children pages? I don't want to have to set the same featured image again and again for children pages...

    Any help would appreciated.

    Many thanks

  2. oakleyarts
    Posted 4 years ago #

    Hi there,

    This one had me baffled too. I've just cracked it and heres how. I just hope its not too late:

    <?php echo get_the_post_thumbnail($post->post_parent, 'thumbnail'); ?>

    Replace 'thumbnail' with a size of your choice. If you want to use an array its this:

    <?php echo get_the_post_thumbnail($post->post_parent, array(680,204)); ?>

    Hope that helps!

  3. trevolutionary
    Posted 3 years ago #

    I obviously must have forgotten about this post, but came across the same problem again, did a search and came across my own post :-) lol

    This is brilliant! It works a treat. Any idea how I would tie this into a conditional that checks for the existence of the thumbnail at that level?

    I tried wrapping it in has_post_thumbnail(), like

    if ( has_post_thumbnail() ) {
    	echo get_the_post_thumbnail($post->post_parent, 'thumbnail');

    But that doesn't seem to work

  4. trevolutionary
    Posted 3 years ago #

    Never mind. After some playing I got it to work. If anyone is interested:

    <?php if ( has_post_thumbnail($post->post_parent, 'pagethumb') ) {
    					 echo get_the_post_thumbnail($post->post_parent, 'pagethumb');
                     	 } else {
                    	 echo do_shortcode('[promoslider category="page" width="620px" height="178px" display_title="none" display_nav="none" time_delay="6"]');
                     } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic