Recent Contributors Widget

A practical use for the new date queries in WP 3.7

| 2 Comments

A couple of weeks ago, Alex Mills (better known as Viper007Bond) wrote a post, noting that a patch he had written for WordPress core had been committed, and will be included in 3.7.

The patch makes specific and complex date queries in WP_Query much easier. This historically has been very difficult, with the date queries only allowing for posts/comments to be pulled for a specific date.

The new date queries allows you to, for example, query posts since a specific date/time, or everything posted on weekdays in the past month. See Alex’s post on complex date queries to read a little more about what’s possible.

This made me think of an application a few years ago that I couldn’t solve. Someone asked me to build them a widget which would show a list of everyone who had contributed to their site in the past month, as a way of recognising them. I soon found that it was more difficult than I thought, and abandoned it.

But after hearing about the new possibilities with date queries, I knew my main problem had been solved.

I built a widget that takes the list of users on your site, runs each one through a WP_Query, using the date query to see if they have written anything in the past 30 days (or however long you want), and if they have, it prints them out to a list.

It’s fairly simple, but it’s a solution to a problem that stumped me a couple of years ago, and now it’s possible.

Expect to see the Recent Contributors Widget in the repository soon.

Categories: Code & Snippets, Plugins | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Let a WordPress Expert help you

Do you want to try this, but feel like you need a helping hand, in case something goes wrong? My service, The WP Butler, gives you access to WordPress expertise whenever you need it. Better yet, I'll keep your site backed up, updated and secure, so that you don't have to worry about it. It's all part of the service. Use coupon DIWW and save 15% on all plans.

Visit The WP Butler

Author:

Dave has been tinkering with WordPress for many years, and he now shares his WordPress knowledge here on Do It WIth WordPress to help others realise its impressive power. He can also be hired to help with your WordPress needs. Dave, who is British, is married to his best friend, Marti, with whom he has a beautiful daughter, Ellie. When he's not dabbling with WordPress, he's probably eating Triscuits or hummus, watching an indie film or British TV show, spending time with friends or family, or exploring the world.

2 Comments

  1. I’m liking the sound of your Recent Contributors Widget – it’s absolutely perfect for my multi-author website and will be installing it as soon as it becomes available.

Leave a Reply