Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)
  • Thread Starter bstojkoski

    (@bstojkoski)

    This is the code I have in this moment:

    
    /*
     * Customizes the HTML output of the WordPress Popular Posts widget.
     *
     * @param	array	$posts
     * @param	array	$options
     * @return	string
     */
    function my_custom_popular_posts_html_list( $posts, $options ){
    
        $output = '<ul class="wpp-list wpp-list-with-thumbnails">';
        $counter = 1;
    
        $first_thumbnail_size = array( 300, 200 ); // Change this
        $regular_thumbnail_size = array( 90, 70 ); // Change this
    
        // loop the array of popular posts objects
        foreach( $posts as $popular ) {
    
            // Thumbnail
            $thumbnail = '';
    
            if (
                $options['thumbnail']['active']
                && has_post_thumbnail( $popular->id )
            ) {
    
                if ( 1 == $counter ) {
                    $thumbnail_src = get_the_post_thumbnail_url( $popular->id, $first_thumbnail_size );
                }
                else {
                    $thumbnail_src = get_the_post_thumbnail_url( $popular->id, $regular_thumbnail_size );
                }
    
                $thumbnail = "<a href=\"" . get_permalink( $popular->id ) . "\"><img src=\"" . $thumbnail_src . "\" class=\"wpp-thumbnail wpp_cached_thumb wpp_featured\" alt=\"" . esc_attr( $popular->title ) . "\"></a>";
    
            }
    
            $output .= "<li>";
            $output .= $thumbnail;
            $output .= "<a href=\"" . get_permalink( $popular->id ) . "\" title=\"" . esc_attr( $popular->title ) . "\" class=\"wpp-post-title\">" . $popular->title . "</a>";
            $output .= "</li>" . "\n";
    
            $counter++;
    
        }
    
        $output .= '</ul>';
    
        return $output;
    
    }
    add_filter( 'wpp_custom_html', 'my_custom_popular_posts_html_list', 10, 2 );
    

    I just need to update it?

    • This reply was modified 8 years, 5 months ago by bstojkoski.
    Thread Starter bstojkoski

    (@bstojkoski)

    Everything is ok now.

    Is it possible to have excerpt only on first post, and add padding from first thumbnail to title 5px?

    Thanks a lot.

    Thread Starter bstojkoski

    (@bstojkoski)

    Hello Hector.

    I think now is ok with the small thumbnails, but the big one is with dimensions 375x250px.

    Thread Starter bstojkoski

    (@bstojkoski)

    I am using W3 Total Cache plugin.

    I think that we should add css class in the code for the first thumbnail.

    Thread Starter bstojkoski

    (@bstojkoski)

    I made the upgrade, and nothing is changed.

    I want to ask you if it’s possible the first post to have excerpt?

    Thread Starter bstojkoski

    (@bstojkoski)

    The last one

    Thread Starter bstojkoski

    (@bstojkoski)

    I added the code, but nothing changed 🙁

    Thread Starter bstojkoski

    (@bstojkoski)

    Someone for support?

    Thread Starter bstojkoski

    (@bstojkoski)

    Hello Hector.

    I updated the plugin to newest version on my website http://pletenje

    I have problem with the small thumbnails. In functions.php I add 290, 200 on big one and 100, 70 for the smaller, but it crop them different.

    Can you please help me?

    Here is the code

    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 = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(300, 200), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail-first') ) . "</a>";
    			$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: 22px;\">{$popular->title}</a>{$excerpt}</li>";
    		} else { // Regular output
    			$thumbnail = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(100, 70), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail') ) . "</a>";
    			$output .= "<li>{$thumbnail} <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 );
    Thread Starter bstojkoski

    (@bstojkoski)

    Hello Hector.

    I updated the plugin to newest version on my website http://pletenje

    I have problem with the small thumbnails. In functions.php I add 290, 200 on big one and 100, 70 for the smaller, but it crop them different.

    Can you please help me?

    Here is the code

    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 = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(300, 200), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail-first') ) . "</a>";
    			$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: 22px;\">{$popular->title}</a>{$excerpt}</li>";
    		} else { // Regular output
    			$thumbnail = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(100, 70), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail') ) . "</a>";
    			$output .= "<li>{$thumbnail} <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 );
    Thread Starter bstojkoski

    (@bstojkoski)

    Hello Hector.

    I update the plugin to newwest version on my website http://pletenje

    I have problem with the small thumbnails. In functions.php I add 290, 200 on big one and 100, 70 for the smaller, but it crop them different.

    Can you please help me?

    Here is the code

    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 = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(300, 200), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail-first') ) . "</a>";
    			$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: 22px;\">{$popular->title}</a>{$excerpt}</li>";
    		} else { // Regular output
    			$thumbnail = "<a href=\"{$permalink}\" title=\"" . esc_attr($popular->title) . "\">" . get_the_post_thumbnail( $popular->id, array(100, 70), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail') ) . "</a>";
    			$output .= "<li>{$thumbnail} <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 );
    Thread Starter bstojkoski

    (@bstojkoski)

    Hector, I am trying to add a permalink on the thumbnails, but I can find solution.

    Can you help me please?

    Thread Starter bstojkoski

    (@bstojkoski)

    Hector, you are awesome dude.

    Plugin works great.

    Thank you very much.
    Branko

    Thread Starter bstojkoski

    (@bstojkoski)

    When I remove this

    $excerpt = " <span class=\"wpp-excerpt\">" . get_excerpt_by_id( $popular->id ) . "</span>";
    		} else { // Regular output

    the widget works. But there is no excerpt, and the thumbnails are 70×70.

    And I want to ask you for help, how can I make the first post title font size bigger?

    You can see the widget on http://pletenje.mk

    Thanks a lot Hector.

    Thread Starter bstojkoski

    (@bstojkoski)

    I am watching the code now, and I see that there is no output for the first post.

    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>";
    		} else { // Regular output
    			$thumbnail = get_the_post_thumbnail( $popular->id, array(90, 70), array('alt' => esc_attr($popular->title), 'title' => esc_attr($popular->title), 'class' => 'wpp-thumbnail') );
    		}
    
    		$output .= "<li>{$thumbnail} <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 );
Viewing 15 replies - 1 through 15 (of 29 total)