WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
WordPress Popular Posts - How do I disable the "No Thumbnail" (2 posts)

  1. keyboardji
    Member
    Posted 2 years ago #

    Hi,

    I love the plugin, but how do I disable the "No Thumbnail" image for posts that don't have a thumbnail. This is how i'd like it to look

    If there's a thumbnail
    thumbnail post_title

    if there's no thumbnail
    post_title

    I have a lot of posts that don't have thumbnails and i'd like to utilize the space better if there's no thumbnail

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

  2. Héctor Cabrera
    Member
    Plugin Author

    Posted 2 years ago #

    Hi keyboardji,

    As of now, there's no way to achieve this without hacking my plugin's code. This is what you need to do:

    # Open wordpress-popular-posts.php using a text editor such as Notepad or Dreamweaver.
    # Find (around line 718):

    if (!function_exists('get_the_post_thumbnail')) { // if the Featured Image is not active, show default thumbnail
        $thumb = "<a href=\"".get_permalink($the_ID)."\" class=\"wppnothumb\" title=\"". $title_attr ."\"><img src=\"". $this->default_thumbnail . "\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$tbWidth."\" height=\"".$tbHeight."\" "."/></a>";
    } else {
        if (has_post_thumbnail( $the_ID )) { // if the post has a thumbnail, get it
            $thumb = "<a href=\"".get_permalink($the_ID)."\" title=\"". $title_attr ."\">" . get_the_post_thumbnail($the_ID, array($tbWidth, $tbHeight), array('class' => 'wpp-thumbnail', 'alt' => $title_attr, 'title' => $title_attr) ) . "</a>";
        } else { // try to generate a post thumbnail from first image attached to post. If it fails, use default thumbnail
            $thumb = "<a href=\"".get_permalink($the_ID)."\" title=\"". $title_attr ."\">" . $this->generate_post_thumbnail($the_ID, array($tbWidth, $tbHeight), array('class' => 'wpp-thumbnail', 'alt' => $title_attr, 'title' => $title_attr) ) ."</a>";
        }
    }

    # ... and replace with:

    if (!function_exists('get_the_post_thumbnail')) { // if the Featured Image is not active, show default thumbnail
        $thumb = "";
    } else {
        if (has_post_thumbnail( $the_ID )) { // if the post has a thumbnail, get it
            $thumb = "<a href=\"".get_permalink($the_ID)."\" title=\"". $title_attr ."\">" . get_the_post_thumbnail($the_ID, array($tbWidth, $tbHeight), array('class' => 'wpp-thumbnail', 'alt' => $title_attr, 'title' => $title_attr) ) . "</a>";
        } else { // try to generate a post thumbnail from first image attached to post. If it fails, use default thumbnail
            $thumb = "";
        }
    }

    # Save changes.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic