Support » Fixing WordPress » Inherit Featured Image into Child Pages

  • Resolved trevolutionary


    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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!

    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

    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"]');
                     } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Inherit Featured Image into Child Pages’ is closed to new replies.