WordPress.org

Ready to get started?Download WordPress

Forums

If page has thumbnail image (5 posts)

  1. acondiff
    Member
    Posted 4 years ago #

    I want to write the following PHP but I dont quite know how.

    if page has thumbnail image, then, (html code) else, do nothing.

    Any help would be great!

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Are you using the_post_thumbnail or do you just means when the post/page has any image attached to it?

  3. acondiff
    Member
    Posted 4 years ago #

    ya, the post thumbnail

  4. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 4 years ago #

    Here's a useful post that helped me with this very thing recently:
    http://wpengineer.com/about-wordpress-post-thumbnail/

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    Try:

    <?php if( get_the_post_thumbnail($post->ID, 'thumbnail') ) the_post_thumbnail(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.