Popular posts to recent posts

hi, thanks so much for this great theme!
i was wondering if there is a simple fix to make the “popular posts” widget actually display recents posts instead?


to make the existing recent posts widget look like the popular posts widget with nice links and thumbnails ?

thanks again!

The only change that you need to make is tweak post order and you can do it by editing file called widget-popular-posts.php that you can find in Sparkling theme folder - inc - widgets.

Now change this line of code:

'orderby' => 'comment_count',

with this one

'orderby' => 'date',

Now posts inside popular posts widget will be ordered by date.

Let me know if there is anything else.

Wondering if there is a simple way to do this changing the orderby to views rather than comments?


Unfortunately, there is no easy way to implement it because WordPress itself doesn’t track views and it is done by third party analytics such as Jetpack, Google Analytics or other. WordPress doesn’t have enough data to create this kind of widget without implementing custom tracking or by pulling information from Analytics or other source. This is not as easy as it might sound.

I think that there should be some plugins that does this kind of things. I am not aware of any but I have built one in the past and believe that there should be some free plugins available as well.

No worries, thanks for the quick response :slight_smile:

Is there any way of choosing which categories shows up in the widget? Would like to separate my blogpost from my project posts.


Unfortunately, it is not possible via WordPRess dashboard but you can do some coding to get this done.

You can create a two separate widgets for projects and for blog posts. For that you need to edit WP_Query which is the function that pulls those posts from database. For more information you can read official WordPress documentation.