ThemeShaper Forums » Thematic

[closed]

Featured Image on a page (not a post) not showing up

(11 posts)
  • Started 2 years ago by aaronrelph
  • Latest reply from helgatheviking
  • This topic is resolved
  1. aaronrelph
    Member

    On each of my pages I have a header image and using the 'featured image' would work perfect but when i set a featured image nothing is showing up on page. Any ideas on what I might be doing wrong?

    Again I am trying to set a full size featured image on a page - not a post.

    Posted 2 years ago #
  2. aaronrelph
    Member

    Anyone out there have an idea what I'm doing wrong?

    Posted 2 years ago #
  3. proto
    Member

    Can you post your website URL in reply if you're not developing locally, that way we can look and try and work out what's causing the problem.

    Posted 2 years ago #
  4. aaronrelph
    Member

    This is the only page I've set a featured image on so far

    http://www.imgonnarelph.com/mha/?page_id=10

    I looked in the code to see why it's not displaying - not seeing any issues though.

    Posted 2 years ago #
  5. not doing anything wrong per se, but featured images don't display on pages by default. you can look at page.php and see that the_post_thumbnail() is nowhere to be found... nor is it hidden in something like thematic_content() b/c page.php just uses wp default the_content(). depending on where you'd like the image to appear you can add it to a hook or filter it into the the_content

    Posted 2 years ago #
  6. aaronrelph
    Member

    @helgatheviking - Thanks so much!!! That's all i need - working perfect now!

    Posted 2 years ago #
  7. @aaron, maybe you could share what you did in case someone else is trying to do the same thing.

    Posted 2 years ago #
  8. aaronrelph
    Member

    I added this code to header.php just above the <main> element. I used a conditional tag so it doesn't show on the front page. All other pages will have a header image if the featured image is set.

    <?php if ( ! is_front_page() ) {?>
    <div class="header-image">
    <?php the_post_thumbnail( 'full' ); ?>
    </div>
    <?php }?>

    Posted 2 years ago #
  9. i get what i asked for. but 'round here we don't advise hacking the thematic core files. and i don't really even advocate creating a child header.php unless you are doing something really whacky.

    you can do what you're trying easily from your child's functions.php

    function kia_add_thumbnail(){
        if ( ! is_front_page() ) {?>
            <div class="header-image"><?php the_post_thumbnail( 'full' ); ?></div>
        <?php }?>
    }
    add_action('thematic_belowheader','kia_add_thumbnail');

    you will need to add another condition so it only will appear on pages and not on blog posts or archives

    Posted 2 years ago #
  10. Bennyboy
    Member

    Helga - that code was exactly what I needed, thanks for posting!

    I have a question related to it - if I wanted child pages of a parent page to display the parent page featured image, what would I use? I assuming it's using 'get_the_post_thumbnail', but I can't get it to pull the parent image.

    Any clues?

    Posted 2 years ago #
  11. http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    the first parameter is post ID. you'll need to find the ID of the parent and use that in get_the_post_thumbnail.

    maybe something like :
    http://www.webcitizenmag.com/2010/05/20/how-to-get-top-parent-page-id-in-wordpress/

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.