Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter laozor

    (@laozor)

    Arf, I was expecting that kind of answer. 🙁

    Nevermind, thanks for the fast help ! Have a good day 🙂

    EDIT : As it may be quite heavy to duplicate the image for each time I want to have the “default”, how viable would it be to set a background image with my default image and using a 1px square transparent image ? Is it something feasible ?

    • This reply was modified 6 years, 7 months ago by laozor.
    Thread Starter laozor

    (@laozor)

    Hello Hector Cabrera !

    Thank you very much for your help ! I had to make some few changes to the code you gave me, so I post my final code here.
    In particular, I had to add a ‘foreach’ concerning the categories, as the code was only returning the word “Array”.. And I added a substr() for my title length 🙂

    function my_custom_single_popular_post( $post_html, $p, $instance ){
        $pp_categories = get_the_category($p->id);
        if($pp_categories){
            foreach ($pp_categories as $pp_category){
                $pp_categoryout = '<a href="'.get_category_link( $pp_category->term_id ).'" class="cat-id-' . $pp_category->term_id . '" title="' . esc_attr( sprintf( __( "Voir tous les articles dans %s" ), $pp_category->name ) ) . '">'.$pp_category->cat_name.'</a>';
            }
        }
        $output = '
            <li class="popular-postid">'
                . get_the_post_thumbnail( $p->id, 'wpp_thumb' ) . '<br />
                <span class="pp-cat">' . trim($pp_categoryout) .'</span><br />
                <a href="'.get_permalink($p->id).'" title="'. esc_attr($p->title) .'" class="wpp-post-title" >'. substr($p->title, 0, 25).' (...)</a><br />
                <span class="pp-date">' . date( 'd M Y', strtotime( $p->date ) ) . '</span>
            </li>';
    
        return $output;
    }
    
    add_filter( 'wpp_post', 'my_custom_single_popular_post', 10, 3 );

    It’s all good now ! Again, thank you very much ! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)