WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
[resolved] [Plugin: WordPress Popular Posts] Remove Link on Image (2 posts)

  1. mikejandreau
    Member
    Posted 3 years ago #

    Just playing around with the plugin, and I want disable the HREF on the thumbnail image, but don't see a setting.

    I'm using both the widget *and* PHP to include it into a page template.

    Is there a way I can still display the Thumbnails, but *not* have them be hrefs?

  2. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Mike,

    Currently, there's no way to do this via parameters. You'll have to hack the code to achieve this.

    Open wordpress-popular-posts.php using an editor such as Windows' Notepad or Adobe Dreamweaver, and change this (around line 690):

    // get thumbnail
    if ($instance['thumbnail']['active'] && $this->thumb ) {
        $tbWidth = $instance['thumbnail']['width'];
        $tbHeight = $instance['thumbnail']['height'];
    
        // default image
        $thumb = "<a href=\"".get_permalink($wppost->ID)."\" class=\"wppnothumb\" title=\"". $title_attr ."\"><img src=\"". $this->pluginDir . "/no_thumb.jpg\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$tbWidth."\" height=\"".$tbHeight."\" "."/></a>";
    
        // let's try to retrieve the post thumbnail!
        if ($instance['thumbnail']['thumb_selection'] == "usergenerated") { // use thumbnail selected by user
            if (function_exists('get_the_post_thumbnail') && has_post_thumbnail( $wppost->ID )) {
                $thumb = "<a href=\"".get_permalink($wppost->ID)."\" title=\"". $title_attr ."\">" . get_the_post_thumbnail($wppost->ID, array($tbWidth), array('class' => 'wpp-thumbnail', 'alt' => $title_attr, 'title' => $title_attr) ) ."</a> <!-- $tbWidth $tbHeight-->";
            }
        } else if ($instance['thumbnail']['thumb_selection'] == "wppgenerated") { // WordPress Popular Posts should attempt to create a thumbnail by itself
            $img = $this->get_img($wppost->ID);
            if ( ($img && !empty($img)) ) {
                $thumb = "<a href=\"".get_permalink($wppost->ID)."\" class=\"wppgen\" title=\"". $title_attr ."\"><img src=\"". $this->pluginDir . "/scripts/timthumb.php?src=". $img[1] ."&h=".$tbHeight."&w=".$tbWidth."&zc=1\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$tbWidth."\" height=\"".$tbHeight."\" "."/></a>";
            }
        }
    }

    ... into this:

    // get thumbnail
    if ($instance['thumbnail']['active'] && $this->thumb ) {
        $tbWidth = $instance['thumbnail']['width'];
        $tbHeight = $instance['thumbnail']['height'];
    
        // default image
        $thumb = "<img src=\"". $this->pluginDir . "/no_thumb.jpg\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$tbWidth."\" height=\"".$tbHeight."\" "."/>";
    
        // let's try to retrieve the post thumbnail!
        if ($instance['thumbnail']['thumb_selection'] == "usergenerated") { // use thumbnail selected by user
            if (function_exists('get_the_post_thumbnail') && has_post_thumbnail( $wppost->ID )) {
                $thumb = get_the_post_thumbnail($wppost->ID, array($tbWidth), array('class' => 'wpp-thumbnail', 'alt' => $title_attr, 'title' => $title_attr) );
            }
        } else if ($instance['thumbnail']['thumb_selection'] == "wppgenerated") { // WordPress Popular Posts should attempt to create a thumbnail by itself
            $img = $this->get_img($wppost->ID);
            if ( ($img && !empty($img)) ) {
                $thumb = "<img src=\"". $this->pluginDir . "/scripts/timthumb.php?src=". $img[1] ."&h=".$tbHeight."&w=".$tbWidth."&zc=1\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$tbWidth."\" height=\"".$tbHeight."\" "."/>";
            }
        }
    }

    That should do the trick.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic