Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Lester Chan

    (@gamerz)

    Sorry that is not possible because the thumbnail is not retrieve from the query to the DB.

    You can do it by editing the plugin code. Look for wp-postviews/wp-postviews.php and search for the function you’ll be using in your widget.

    In my case I am using most viewed pages/post. So I scrolled down and find:

    ### Function: Display Most Viewed Page/Post

    Then you look for the last $temp line (within that function):

    $temp = str_replace("%POST_TIME%", get_the_time(get_option('time_format'), $post), $temp);

    And you add this right below:
    $temp = str_replace("%POST_IMG%", get_the_post_thumbnail(), $temp);

    Now, get back to the template and set it using %POST_IMG% wherever you want the image to appear:

    <li>%POST_IMG%<br /><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a></li>

    Remember to have a fallback image: https://justintadlock.com/archives/2012/07/05/how-to-define-a-default-post-thumbnail

    This is actually pretty simple and could come with the plugin.

    Plugin Author Lester Chan

    (@gamerz)

    Is not that straightforward with the current code base. By using get_the_post_thumbnail(), you will incur 1 query for every post make. So if you are showing Top 20 Most Viewed Post, it will have additional 20 queries.

    A better way of doing this will be to use query_post() to replace the existing widget sql query. That is on my to-do list.

    Do you finish? And how to replace the existing widget sql query with query_post() ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Thumbnail in Widget’ is closed to new replies.