Limit tag cloud terms by date

Well it’s not that it’s not possible it just means it will take some effort. I am able to use an SQL query that combines the posts, term_relationships and terms tables. This allows a tag or name to be associated with a post which was published on a particular date. This was the sql statement i used ->

select * from lwdev_posts p JOIN lwdev_term_relationships r ON p.id=r.object_id JOIN lwdev_terms t ON r.term_taxonomy_id=t.term_id where p.post_status="publish"

If you are not familiar with SQL this basically means combine the three tables and show all columns that are published.

You can narrow this down to just the term and the date with the following ->

select p.post_date, t.name from lwdev_posts p JOIN lwdev_term_relationships r ON p.id=r.object_id JOIN lwdev_terms t ON r.term_taxonomy_id=t.term_id where p.post_status="publish"

So you have some data you can work with to produce your tag cloud. If you want to specify a date range then use the following ->

 select p.post_date, t.name from lwdev_posts p JOIN lwdev_term_relationships r ON p.id=r.object_id JOIN lwdev_terms t ON r.term_taxonomy_id=t.term_id where p.post_status="publish"
    AND p.post_date BETWEEN '2012-07-24' AND '2012-08-01' 

Replace lwdev_ with your table prefix. Using some php and searching for a custom tag cloud method you will be able to use the sql to return all the terms, and then use some php to specify the date.

One thing to note if you do not GROUP BY the term name then you will get a list of the same terms associated with a different post date. If you do GROUP BY the name then it will choose the earliest post date.

Check the sql in phpmyadmin and test the query to tailor your results. Hopefully someone has written an easier way to do all this, you might need some custom php functions to get the desired effect but it seems possible, just laborious. Hope this in some way helps.