• Resolved JonWicks25

    (@jonwicks25)


    I’m currently working on my own theme, I only have it locally sadly.

    Basically in the header I have a the navigation and then the featured image of the page, then a second navigation menu

    ———- Nav ——–
    —– Feature Image —–
    ——– 2nd Nav ——–

    I want only the parent pages to have featured images, and so the on a child page the feature image should be the same as it’s parent,

    this is my code

    <?php
       if ( is_page('home')) {
         echo '<div style="float: left;">';
         echo riva_slider_pro( 1 );
         echo '</div>';
    } else if (is_page('our-clients' || 'our-services' || 'about' || 'our-team' || 'our-sectors' || 'information' || 'partners' || 'contact-us')) {
         echo '<div style="height: 170px;">';
         echo get_the_post_thumbnail($page->ID, 'full');
         echo '</div>';
    } else  {
         echo '<div style="height: 170px;">';
         echo get_the_post_thumbnail($post->post_parent, 'full');
         echo '</div>';
     }
    ?>

    Individually each piece works fine, but all together I can’t get the child pages to pull the same featured image as the parent. Am I missing something simple?

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter JonWicks25

    (@jonwicks25)

    Never mind got it sorted. If anyone else is having similar problems this is the correct code I used

    <?php
    if ( is_page('home')) {
       echo '<div style="float: left;">';
       echo riva_slider_pro( 1 );
       echo '</div>';
    } else if (is_page('our-clients') || is_page('our-services') || is_page('our-team') || is_page('our-sectors') ||  is_page('information') || is_page('partners') || is_page('contact-us') || is_page('about')) {
       echo '<div style="height: 170px;">';
       echo get_the_post_thumbnail($page->ID, 'full');
       echo '</div>';
    } else  {
       echo '<div style="height: 170px;">';
       echo get_the_post_thumbnail($post->post_parent, 'full');
       echo '</div>';
    }
    ?>

    I had the coding for else if (is_page(‘page’) || wrong

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Call Parent Thumbnail’ is closed to new replies.