Support » Plugin: WordPress Popular Posts » Unable to display date and featured image

  • Any idea on how to display the featured image of a post? I am using the wpp_get_mostpopular() in single.php. I am not able to display date (day and month) also. Here is my code below

    <?php
    
                    	if (function_exists('wpp_get_mostpopular')) {
    					wpp_get_mostpopular(array(
    					'limit' => 4,
    					'range' => 'last7days',
    					'order_by' => 'views',
    					'wpp_start' => '',
    					'wpp_end' =>'',
    					'thumbnail_width' => 50,
    					'thumbnail_height' => 50,
    					'post_html' => '
    					<div class="card card-body bg-light shadow-sm border-0 mb-5">
    	                  <div class="row">
    	                    <div class="col-4 col-md-5 col-lg-5 pe-lg-0 pos-rel">
    	                      {thumb_img}
    	                      <div class="date-box tx-14 tx-gray text-center content-pos">
    	                        <span class="fw-bold">{date}</span>
    	                      </div>
    	                    </div>
    	                    <div class="col-8 col-md-7">
    	                      <p class="tx-24 fw-bold mb-1 col-lg-9 blogpost-tx">{text_title}</p>
    	                      <div class="pt-4 pt-md-5">
    	                        <a href="{url}" class="fw-bold tx-24"> More Info
    	                          <img src="'.get_template_directory_uri().'/assets/img/icons/arrow-right.svg" alt="" srcset="" class="ms-5">
    	                          </a>
    	                      </div>
    	                    </div>
    	                  </div>
    	                </div>
    					'
    
    					));
    					}
    				?>
    
    • This topic was modified 3 months, 1 week ago by taymi.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Héctor Cabrera

    (@hcabrera)

    Hi @taymi,

    Any idea on how to display the featured image of a post?

    Just tested your code as is -without any modifications whatsoever- and it displayed thumbnails just fine (except for one post because it doesn’t have a featured image assigned to it).

    It might be a good idea to check these FAQs to figure out why WPP is not displaying thumbnails on your website:

    I am not able to display date (day and month) also.

    To display the date you also need to use the stats_date parameter. Right now it’s missing from your code. This is mentioned on the Content Tags documentation:

    {date}: returns post/page date, requires stats_date to be 1

    So:

    if (function_exists('wpp_get_mostpopular')) {
        wpp_get_mostpopular(array(
            'limit' => 4,
            'range' => 'last7days',
            'order_by' => 'views',
            'stats_date' => 1, // <== Added by me
            'wpp_start' => '',
            'wpp_end' =>'',
            'thumbnail_width' => 50,
            'thumbnail_height' => 50,
            'post_html' => '
            <div class="card card-body bg-light shadow-sm border-0 mb-5">
                <div class="row">
                    <div class="col-4 col-md-5 col-lg-5 pe-lg-0 pos-rel">
                        {thumb_img}
                        <div class="date-box tx-14 tx-gray text-center content-pos">
                            <span class="fw-bold">{date}</span>
                        </div>
                    </div>
                    <div class="col-8 col-md-7">
                        <p class="tx-24 fw-bold mb-1 col-lg-9 blogpost-tx">{text_title}</p>
                        <div class="pt-4 pt-md-5">
                            <a href="{url}" class="fw-bold tx-24"> More Info
                            <img src="'.get_template_directory_uri().'/assets/img/icons/arrow-right.svg" alt="" srcset="" class="ms-5">
                            </a>
                        </div>
                    </div>
                </div>
            </div>'
        ));
    }

    To set the date format you can use the stats_date_format parameter (see Parameters for more details).

    If you have any other questions please don’t hesitate to ask.

    Thread Starter taymi

    (@taymi)

    Thank you for the response @hcabrera

    I have been able to fix the date and yes.. I saw how the thumbnail works. Unfortunately, it does not still work for me. I have also tried {thumb_url} inside an tag. Settings looks fine and told to pick up from Featured Image, after all these, placeholder is still displayed.

    Plugin Author Héctor Cabrera

    (@hcabrera)

    That’s odd. Alright, please try following the troubleshooting instructions and report back your findings.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.