Support » Fixing WordPress » How to recursively apply a "Featured image" to sub pages?

  • Hello, just as the subject states, I am looking for a way to recursively apply a featured image downward to any sub pages, while allowing for a sub page featured image (if set) to override a parent’s featured image. Is this possible?

    thanks 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am hunting down an answer for this as well, robotor. Did you find anything since you posted?

    I’m getting close, mashing up code like a Primanti Brothers sandwich from various readings, codex etc.

    I need this to do “if is parent, display current featured. Else display 1st level featured image.” The code below only displays the parent page of the child pages so when in 3rd level it displays the 2nd level apparently. Not sure about overriding but it’s a step closer than where I was.

    <div id="featured">
     <?php if (has_post_thumbnail( $post->post_parent ) ): ?>
     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->post_parent ), 'single-post-thumbnail' ); ?>
     <div id="featured-bg">
     <img src="<?php echo $image[0]; ?>" alt="Title here" />
     <div id="featured-caption"><?php echo the_post_thumbnail_caption(); ?></div>
     <?php endif; ?>

    I have a solution here with the option to override the parent page’s featured image with a featured image added to a child page.

    Let me know if you have any trouble with it or feedback/improvements. I’ll likely re-use this for a ton of projects and improve it as needed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to recursively apply a "Featured image" to sub pages?’ is closed to new replies.