WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] thumbnails if, if not help

[Resolved] thumbnails if, if not help

  • I’m looking for a way to get this code to show thumbnails IF they page is called page1, page2 and so on:

    <?php if(has_post_thumbnail()) { ?>
    <?php the_post_thumbnail('homeblog'); ?>
    <?php } ?>

    How can i write that?

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    @esmi

    Forum Moderator

    is_single( array( 'beef-stew', 'pea-soup', 'chili' ) )
    i guys this is the code?

    I’m really not good at php, but is it like this then:

    <?php if(has_post_thumbnail(is_single( array( 'beef-stew', 'pea-soup', 'chili' ) ) )) { ?>
    <?php the_post_thumbnail('homeblog'); ?>
    <?php } ?>

    ??

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    esmi

    @esmi

    Forum Moderator

    That code would only show post thumbnails on single posts with the slugs beef-stew’ or pea-soup, yes.

    I have a page named “contact” so the could so be:

    <?php if(has_post_thumbnail(is_single( array( 'contact' ) ) )) { ?>
    <?php the_post_thumbnail('homeblog'); ?>
    <?php } ?>

    But it’s not working :/

    [No bumping. If it’s that urgent, consider hiring someone.]

    esmi

    @esmi

    Forum Moderator

    Try:

    <?php if( is_single( 'contact') && has_post_thumbnail() ) the_post_thumbnail('homeblog');?>

    It does not seem to work 🙁

    The code is placed in top_info.php, can that have anything to say?

    what should I put instead of homeblog?

    Thank you very much for your help!

    esmi

    @esmi

    Forum Moderator

    can that have anything to say

    Possibly. What theme are you using?

    Moderator Michael

    @alchymyth

    Forum Moderator

    have a page named “contact”

    for pages, use is_page()

    http://codex.wordpress.org/Function_Reference/is_page

    Thank you both so much!!!

    The code is working:

    <?php if( is_page('contact') && has_post_thumbnail() ) the_post_thumbnail('somethingrandomiguess');?>

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] thumbnails if, if not help’ is closed to new replies.