Welcome to PressWork!

Want to ask a question or join the discussion? Great! Join now.

In this Discussion

Display featured image on page (Last Question)
  • Hello,

    This is my last question, I swear, I'm just getting into PHP.

    I have been trying to figure out how to show a PAGE'S featured image in the same place as a POST'S, however, when I add the code:
    <?php if(is_page()) { ?> 
    <?php if(function_exists('has_post_thumbnail') && has_post_thumbnail()) {
    if(empty($ignore_image) || has_post_format('image')) {
    echo '<a href="'.get_permalink().'" class="image-anchor">';
    the_post_thumbnail($size, array( 'class' => 'ifonpost' ));
    echo '</a>';
    } ?>

    I get a function error and my site becomes unavailable, so I have to remove it through FTP.

    Secondly, when I use <?php is_page() { ?> it displays the featured image properly, but it also makes the post's image display twice. How do I add the code properly to display only on a page, not on a post twice?

    I'd also like to know how to hide the way it shows an image attachment at the bottom of each article/page for images added, making them only display where I insert them. Cheers!
  • I should explain more:

    My website is http://timerball.com and I set posts to show the featured image thumbnail even on their unique (is_single) pages. I am wondering how to repeat this, but for pages as well, however, when I make it do (is_page) it also makes it repeat the image on (is_single).

    when I set a featured image or upload images to wordpress, at the end of the post it shows attachments AGAIN apart from where I insert them.
  • cbavotacbavota
    This answer was Accepted.
    In the code above it looks like you are missing a closing "}" from the is_page() statement. You can also remove the $ignore_image if statement so you code looks like this:
    if(is_page()) {
    if(function_exists('has_post_thumbnail') && has_post_thumbnail()) {
    echo '<a href="'.get_permalink().'" class="image-anchor">';
    the_post_thumbnail($size, array( 'class' => 'ifonpost' ));
    echo '</a>';
    image Senior Developer & Co-Founder of PressWork
  • Thank you very much! That fixed the first issue, however, how would I go about making the attachments at the bottom disappear?
  • Figured it out. Thanks!