Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Neofalinas

    (@neofalinas)

    Maybe I should specify: I need only the first post thumbnail to be shown.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there,

    You already posted here, so there’s no need to create a new topic. I’m requesting a mod to close/delete this one.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Actually this is a separate topic for a new poster, and that’s what we ask people to do ?? Better to ask here in a non-resolved topic we feel.

    Plugin Author Hector Cabrera

    (@hcabrera)

    I guess you have a point. Alright then, I’ll let it be.

    To the OP, I have already replied on the other topic so please make sure you go there first.

    Thread Starter Neofalinas

    (@neofalinas)

    Sorry Hector for all the confusing regarding your side, but I thought It would be wiser to open a new thread about it.

    I followed your guide, and I succeeded to make thumbnails: 1 larger for first element and two others a bit smaller. Tho, I would like to ask you, if there’s a way, to only have 1 large thumbnail for first post, and others should only contain titles of posts. If I try to tinker the code you provided, I end up only with same thumbnails for all posts ??

    Bonus: I would like to have a border of some sort, so it would be visually easier to read the content of this amazing plugin ??

    Thank you for your patience, as I am just a starter :/

    Plugin Author Hector Cabrera

    (@hcabrera)

    Don’t worry about it, we are all learning here.

    Alright, to have the plugin display a thumbnail only for the first post change the custom_popular() function into this:

    function custom_popular( $mostpopular, $instance ){
    	$counter = 0;
    
        $output = '<ul class="wpp-list">';	
    
    	foreach( $mostpopular as $popular ) {
    
    		$permalink = get_permalink($popular->id);
    		$excerpt = "";
    
    		// Different output for the first post: show different thumbnail and post excerpt (summary)
    		if ( 0 == $counter ) {
    
    			$thumbnail = get_the_post_thumbnail( $popular->id, array(300, 200), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail') );
    			$excerpt = " <span class=\"wpp-excerpt\">" . get_excerpt_by_id( $popular->id ) . "</span>";
    			$output .= "<li>{$thumbnail} <a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\" style=\"font-size: 18px;\">{$popular->title}</a>{$excerpt}</li>";
    
    		} else { // Regular output, no thumbnail
    			$output .= "<li><a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">{$popular->title}</a>{$excerpt}</li>";
    		}
    
    		$counter++;
    	}
    
    	$output .= '</ul>';
    
    	return $output;
    }
    add_filter( 'wpp_custom_html', 'custom_popular', 10, 2 );

    Bonus: I would like to have a border of some sort, so it would be visually easier to read the content of this amazing plugin ??

    What do you mean?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Since the OP hasn’t replied in a week now, I’m marking this topic as resolved.

    @neofalinas if you require further help with the code I posted above, please let me know.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘First in list with thumbnail’ is closed to new replies.