WordPress.org

Ready to get started?Download WordPress

Forums

hide post thumbnail with custom field? (5 posts)

  1. arthurdent2003
    Member
    Posted 3 years ago #

    Hi!

    I want to hide a thumbnail in a post - but only in the single view (the post thumbnail should show up everywhere else).

    I tried it with a custom field called hidethumb, so when it is activated it should just show nothing but doesn't work:

    <?php

    $hidethumb = get_post_meta($post->ID, "hidethumb", true);

    if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
    the_post_thumbnail(array(150,150), array("class" => "alignleft post_thumbnail"));

    else if ($hidethumb) {
    echo "";}
    ?>

    any suggestion?

    Thank you!!

    AD

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    you are testing for your custom field after the post thumbnail is shown, and only if there is no post thumb.

    try:

    <?php
    
    $hidethumb = get_post_meta($post->ID, "hidethumb", true); 
    
    if ( !$hidethumb && function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
    the_post_thumbnail(array(150,150), array("class" => "alignleft post_thumbnail"));
    
    ?>
  3. arthurdent2003
    Member
    Posted 3 years ago #

    Hi alchymyth,

    thank you for the reply! Works!

    AD

  4. anjoid
    Member
    Posted 2 years ago #

    Hoping one of you can help, I'm having a similar issue and its driving me crazy. I would like to hide the post thumbnails on certain single pages/categories. Here is a link to my site http://www.wellnessbysandra.com/new

    I would like to remove the thumbs on the tip pages...

    any help will be greatly appreciated!

  5. AdeleMB
    Member
    Posted 2 years ago #

    Same as anjoid, I also want to hide post thumbnails on single posts, but only on posts using a specific category (in my case 'graphics').

    Thank you for any help! :-)

Topic Closed

This topic has been closed to new replies.

About this Topic