-
Archives for a category WordPress plugin
For the new version of this website I wanted to show a list of monthly archives, limited to posts of a specific category. The software used to run this website is WordPress but the
wp_get_archives()function, to get a list of archives, does not have the ability to filter on category. So I created the ‘Archives for a category’ plugin that enhances this function to show archive links for a specific category.Installation
- Download the plugin zip file and unzip the file in a temporary directory.
- Put the
kwebble_archives_by_cat.phpfile in your WordPress plugin directory:
<your wordpress dir>/wp-content/plugins - Activate the plugin ‘Archives for a category’ on the Plugin Management page of the WordPress administration panel.
- Optionally disable the canonical URLs from the menu Settings | Kwebble.
A WordPress feature added in version 2.3, called canonical URLs, redirects browsers on certain URLs. This also happens with the URLs for the archives with a cat parameter. This causes the archive pages to contain posts which do not belong to the selected period.To solve this problem the plugin can disable canonical URLs. This uses the technique used in the Disable Canonical URL Redirection plugin Mark Jaquith made. So if you are already using that plugin you don’t need to change the setting for this plugin.
To disable canonical URLs go to the administration section of your blog, choose Settings and the Kwebble settings. On that page you will find a checkbox to disable canonical URLs.
Usage
After installing and activating the plugin the
wp_get_archives()function accepts a ‘cat’ parameter to specify the categories of posts to show in the list of archives. The value of the ‘cat’ parameter must be a list of one or more category ID’s, separated by comma’s.If you specify the value of a category ID the posts from that category will be used to create the list of archives. If you place a minus sign ‘-’ in front of an ID the posts from that category will be excluded.
Depending on the number of categories, your use of them and selection of categories to include in the archive list it may be easier to specify all categories to include or just those to exclude.
You need to make sure the template used to show each archive displays posts from the selected category. I’m using category specific templates on this site, like category-id where id is the ID of the category to display. You can use other templates in the template hierarchy, but make sure the template shows items of the categories you specify.
At some WordPress version the categories ID’s are no longer visible on the administration pages. You can find the ID of a category by opening the page to edit the category and inspect the URL of that page. The value after cat_ID= is the ID of the category.
Examples
Show the default monthly list of archives for category 1:
<?php wp_get_archives('cat=1'); ?>The same list, but with posts from categories 1 and 3:
<?php wp_get_archives('cat=1,3'); ?>Use posts from all categories except category 2:
<?php wp_get_archives('cat=-2'); ?>Use posts from all categories except categories 2 and 8:
<?php wp_get_archives('cat=-2,-8'); ?>Create a list of archives for category 1 as a dropdown box:
<?php wp_get_archives('format=option&cat=1'); ?>Limitations
This plugin does not work for weekly archives. The list with archive links is correct, but the links themselves do not include the category. So when used, WordPress will not filter the resulting page on the category. The technical reason is that WordPress does not apply filters when the links for weekly archives are generated, so the plugin can’t change them. Perhaps in a next version of WordPress…
This plug-in was developed and tested to work correctly with WordPress version 2.7.1, but it probably works with earlier versions back to 2.2.1.
Older versions
These are earlier versions of the plugin. Use them only if you have a specific reason for not installing the current version.
Version 1.4a
27-03-2009 Download
- Corrected post count when posts belong to multiple categories.
- SQL queries now respect the configured SQL table prefix.
- Templates with multiple calls to wp_get_archives(), with and without ‘cat’ parameter, generate correct URL’s.
Version 1.4
22-02-2009 – Added option to exclude categories. Download.
Version 1.3
6-01-2008 – Added support for multiple categories. Download.
Version 1.2
23-11-2007 – Added support for WordPress 2.3.1. Download.
Version 1.0
15-08-2007 – Initial version, works with WordPress 2.2.1. Download.
Copyright
Copyright 2007, 2008, 2009 Rob Schlüter. All rights reserved.
Licensing terms
- You may use, change and redistribute this software provided the copyright notice above is included.
- This software is provided without warranty, you use it at your own risk.
175 Reacties
Trackbacks
- WordPress 2.3 compatiblity Plugins | Dreamer's Blog
- WordPress Plugins Database » Plugin Details » Archives for a category
- 2pt3 › archive » wordpress tips
- AWSOM.org = Artist Website Setup Options Markup » Blog Archive » AWSOM Archive 1.4.0 released
- Archives for a category WordPress plugin
- DIY Podcasting on Wordpress | How-tos | ministrypool.com
- Removing Categories From A Wordpress Feed | /timelliott
- Plugins para Wordpress « La mala memoria
- Sugar Blog » Westgate Dental gets a facelift
- Archives for a category WordPress plugin (Kwebble blog) « wp-popular.com
- Include/Exclude Category from Wordpress wp_get_archives() | The Mighty Mo! Design Co. | Minneapolis Wordpress Developers and Designers
- Wordpress site for Hampshire Primary School « Sugar Blog
- WordPress Plugins, die codeline.ch ermöglichen | codeline
- Broken Link Checker und andere tolle WordPress-Plugins | Ginchens Blog
- Wordpress Monthly Archives for a Category | Design Onslaught
- Archives for a category « ???
- Using WordPress 3 as a CMS | Blog | Reveloper
- Alex Barber | Digital Artist | WordPress archives for a category
- ????????????? ??WP??? Lifestream ?????? / Devslog
- ????????????? ??WP??? Lifestream ?????? / Devslog
Queenvictoria 4-10-2007 (22:08)
thanks kwebble for this . here is the update to make it work with the v2.3 version of wordpress .
function kwebble_getarchives_where_for_category($where, $args){
global $kwebble_getarchives_data;
if (isset($args['cat'])){
// Preserve the category for later use.
$kwebble_getarchives_data['cat'] = $args['cat'];
if ( get_bloginfo('version') > 2.3 )
$where .= ' AND post2cat.category_id=' . $args['cat'];
else
$where .= " AND taxonomy.taxonomy = 'category' AND taxonomy.term_id = " . $args['cat'];
}
return $where;
}
and later
function kwebble_getarchives_join_for_category($join, $args){
global $wpdb;
if (isset($args['cat'])){
if ( get_bloginfo('version') > 2.3 )
$join .= ' JOIN ' . $wpdb->post2cat . ' post2cat ON post2cat.post_id=ID';
else
$join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = taxonomy.term_taxonomy_id) ";
}
return $join;
}
Queenvictoria 4-10-2007 (22:14)
sorry that should be less than not greater than 2.3
function kwebble_getarchives_where_for_category($where, $args){
global $kwebble_getarchives_data;
if (isset($args['cat'])){
// Preserve the category for later use.
$kwebble_getarchives_data['cat'] = $args['cat'];
if ( get_bloginfo('version')
and later
function kwebble_getarchives_join_for_category($join, $args){
global $wpdb;
if (isset($args['cat'])){
if ( get_bloginfo('version') post2cat . ' post2cat ON post2cat.post_id=ID';
else
$join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = taxonomy.term_taxonomy_id) ";
}
return $join;
}
Rob Schlüter 5-10-2007 (20:00)
Thanks, I didn’t realize the plugin needed an upgrade for the new Wordpress version.
I’ll test this when I upgrade my site to the 2.3 version and if everything is ok I will post a new version of the plugin.
Mike 31-10-2007 (20:22)
Just installed the plugin myself (within WP v2.3.1) and it needed queenvictoria’s modification.
However, if you are going to try it yourself: just copy & paste the code from queenvictoria’s FIRST post (from “4 october 2007, 22:08) and then modify the ‘greater than’ symbol to a ‘less than’ by hand in BOTH instances.
It looks as if the code got messed up when submitting the second post (from “4 october 2007, 22:14″)
Rob Schlüter 1-11-2007 (9:28)
Thanks for the note.
In the coming days I’m upgrading my development version of the site to WordPress 2.3.1. Then, if everything works ok, I’ll upgrade my site and make a new version of this plugin available.
jay 20-11-2007 (16:11)
If you’re going to use this with WordPress 2.3, you’ll have to use the plugin which disables canonical redirects. The new version of Wordpress doesn’t correctly process the URLs to show archives only in a given cat. (Specifically URLs like /2007/10/?cat=1 won’t work unless canonical URLs are disabled.)
Here’s the plugin…
http://txfx.net/files/wordpress/disable-canonical-redirects.phps
Rob Schlüter 21-11-2007 (21:58)
At the moment I’m testing a new version of the plugin and also noticed that the URL’s generated by the plugin are redirected incorrectly creating archive pagess with incorrect posts.
To solve this I’m adding the possibility to disable canonical URLs from the administration menu.
Rob Schlüter 23-11-2007 (23:30)
A new version (1.2) with WordPress 2.3 support is now available.
stephen 29-12-2007 (10:12)
This is really great, but I was wondering if there was a way to show multiple categories.
Rob Schlüter 30-12-2007 (23:57)
Using multiple categories is not possible at the moment. I’ll have a look to see if I can add support for more than 1 category.
steve 1-01-2008 (23:24)
That would be great!
Rob Schlüter 6-01-2008 (14:29)
Just updated the plugin to version 1.3, which adds support for multiple categories.
jack 22-01-2008 (2:32)
exactly what I needed, thanks!
Tony 23-01-2008 (4:34)
Hi, this was exactly what I was looking for! And using it along with the category-id.php works very well! Thank you so much!
cj 25-02-2008 (23:33)
Hi, love the plug-in, it works great. One question though, is there a way to make the monthly category archives use the archive template instead of the category template? Thanks
Rob Schlüter 26-02-2008 (13:19)
cj, perhaps you could rename the category template and create a new one that checks if a category or archive page is requested, and
include()the appropriate template.I think you’ll have check for a part in the URL that identifies the requested page type, for example a date pattern, because the
is_archive()is also true for category pages, according to the Codex .slambert 11-03-2008 (6:46)
this is great. Curious if it’s possible to show the number of posts next to the month and year. for example August 2007 (6) If there were 6 posts from that month.
Rob Schlüter 14-03-2008 (21:37)
@slambert: does the parameter show_post_count you can use with wp_get_archives do what you need?
slambert 16-03-2008 (23:55)
@rob Schülter: yes and no. That’s the functionality, but I still want to filter it by category. Make sense?
Zef 13-04-2008 (0:41)
Just posting to say thank you SO much for creating this plugin. I’ve had a day of searching and you have saved my website!
Tom 28-04-2008 (20:07)
I just noticed that this plugin doesn’t work in Wordpress 2.5. Any plans to update it? Thanks for your work so far — it’s a very helpful plugin.
Rob Schlüter 28-04-2008 (22:01)
I will investigate what’s the reason 2.5 breaks the plugin.
tom 20-05-2008 (14:37)
@rob: I was wrong. It IS in fact working in Wordpress 2.5. Sorry for the confusion.
Chi 21-05-2008 (17:15)
Hi.. Nice plugin.. Unfortunately, it isn’t retreiving children category posts.. Pls help!
Rob Schlüter 22-05-2008 (8:12)
It need some time to find out how to generate a URL that includes all child categories.
If the category structure of your site isn’t that complex and doesn’t change often then, as a temporary solution, you could add the child categories to the cat parameter, separated by comma’s:
<?php wp_get_archives('cat=1,3,7,8,19'); ?>This will include posts from all those categories in the archive.
Jeff 3-07-2008 (13:13)
Just wanted to say thank you. Really appreciate the work
Nicole 16-07-2008 (0:42)
Hi there,
great plugin and easy to use!
Just wondering, I want to Archive via Year, not month.. can this plugin do that?
Rob Schlüter 16-07-2008 (8:17)
wp_get_archives can generate yearly archives by using the type parameter, which is part of WordPress itself. Use something like this to combine it with a category selection:
<?php wp_get_archives('type=yearly&cat=1'); ?>ann 15-08-2008 (20:08)
thanks! this saved me tons of headache!
Steve Meisner 2-09-2008 (20:04)
Thanks, it works great in 2.6.1.
Paul 8-10-2008 (11:01)
with this plugin will the function accept negative value, that is can this be used to EXCLUDE certain categories from being listed, that is filter out ?
Rob Schlüter 8-10-2008 (12:39)
No, you can’t exclude categories by using negative values.
It would require some changes to the way the cat parameter is placed in the SQL to select matching posts.
Paul 8-10-2008 (12:48)
ok, i can work around it – im my case im trying to use it to publish a news (facts) index section, actually a category, and keep it separate to a blog (opinion) section even though they run off 99% similar standard blog templates.
Carl-Johan 20-12-2008 (0:19)
Great plugin! This should really become a basic function in wordpress. Maybe you could submit it to them.
Rob Schlüter 20-12-2008 (14:08)
@Carl-Johan in the current situation this plugin conflicts with the canonical URLs feature. That should be resolved to be included, I expect.
, it would be a useful addition.
But surely I agree
anders 21-01-2009 (12:36)
Hi!
Is it possible to exclude categories with this plugin this also?
f.ex:
wp_get_archives(’type=monthly&cat=-7′);
If not it would be great if you added this in a later edition! ;D
Rob Schlüter 21-01-2009 (13:36)
@anders: no, excluding doesn’t work. I’ll have a look to see if it’s not too difficult to add since you are the second person asking for it.
anders 23-01-2009 (9:02)
thanks! ;D
and one more thing!
Is it a way to display a category (by ID) and all childrens of that category, without typing their ID in?
Russ 2-02-2009 (19:45)
Great plugin! It did EXACTLY what I needed it to. Super-easy and brilliant!
luke 3-02-2009 (20:00)
thanks!
exactly what i need…..
Susan 9-02-2009 (19:07)
Amazing — I searched for something I had expected WP to handle but did not, ie,:
and you immediately solve the problem with #1 hit.
Thank you!
Susan 9-02-2009 (19:09)
search term didn’t show up. It was
Susan 9-02-2009 (19:10)
one more try
“”
Jonathan 16-02-2009 (2:42)
Would also love it if this would allow for category exclusion
.
Sarah 17-02-2009 (11:33)
I wish this was 2.7 compatible.
Is there any chance you’ll update it?
Please?
Rob Schlüter 17-02-2009 (14:31)
@sarah: I haven’t heard about problems with 2.7 and since I don’t use that version myself, could you let me know what problems you encounter?
damien 20-02-2009 (13:04)
@Rob Schlüter
and How to exclude categories?
and can I create a list of archives, with posts from categories 1 AND 3 (! its not a 1 OR 3)?
Rob Schlüter 20-02-2009 (23:03)
Sorry Damien, at the moment only posts from the selected categories, no AND/OR/EXCLUDE.
Rob Schlüter 22-02-2009 (22:55)
Version 1.4 is now available. Now you can exclude posts from categories by putting a minus sign (-) in front of a category ID.
It’s a fresh version that’s only been tested on a development environment, but it looks OK. Enjoy.
damien 23-02-2009 (12:59)
How to use your plugin with the tags?
Thank you for updating!
Rob Schlüter 23-02-2009 (13:44)
@damien: see ‘Examples’ on this page for the syntax you have to use.
peach 3-03-2009 (23:38)
fyi – works great in wp 2.7.1. thanks!
Vlad 17-03-2009 (8:30)
Hello Rob,
Thanks for developing this plugin.
I think I have found a bug – if I have a post that belongs to two categories, it will be displayed twice in the archives when I use the &cat parameter. The only way to avoid this is to make the cat parameter specify ONE of the categories it belongs to.
For example, if my post is a member of categories 3 and 5 and I do &cat=-1, it will be listed twice, but if I do &cat=-1,3 then the post will be listed once.
I think this just requires a small change to the plugin’s WHERE or JOIN query, but I cannot figure it out myself as I am unfamiliar with WordPress’ schema.
I am using WordPress 2.7.1.
wp 23-03-2009 (4:06)
this plugin is a lifesaver. thanks!
danjothebanjo 25-03-2009 (17:58)
Hi There – your plugin is the only thing out there that does what I needed thanks! Just one thing i saw above that one of your users also wondered how to force the request to use the archive template rather than the category template. As soon as I pass the cat parameter to the function it starts using the category template? Any ideas?
Thanks again.
Rob Schlüter 25-03-2009 (22:10)
@vlad: correct, in the described situation the post count is wrong. I’m figuring out a solution
@danjothebanje: true, according to the template hierarchy when a category is present in the request the category template is preferred over the archive template. Perhaps you can use is_archive() in the category template to test if an archive is requested or not and include the appropriate template.
danjothebanjo 26-03-2009 (12:25)
thanks Rob, I actually used is_date() in a conditional statement in my category template to get the template looking right – thanks again
Rob Schlüter 27-03-2009 (13:58)
Version 1.4a is available for download. Changes:
- Corrected post count when posts belong to multiple categories.
- SQL queries now respect the configured SQL table prefix.
- Templates with multiple calls to wp_get_archives(), with and without ‘cat’ parameter, generate correct URL’s.
enjoy
Becky 27-03-2009 (23:56)
It’s not working for me. I used and nothing is showing up. What am i missing?
Rob Schlüter 28-03-2009 (12:25)
Becky, could you give me some more information? What is not showing, the list of archives or the complete page with archived posts?
And how does the call to wp_get_archives() look like? Does it include the ‘cat’ parameter to select categories?
bill 3-04-2009 (23:23)
Rob- Thanks for your work on this plugin.
If I understand correctly, in order to get the sidebar archive widget to only show a particular category, I need to edit the widget.php file as follows:
becomes
There are 2 instances of the wp_get_archives() in widgets.php. Do I need to edit both? Am I doing the edits in correct file? Thanks.
Rob Schlüter 5-04-2009 (19:06)
@bill: I haven’t used widgets and don’t really know much about them. widgets.php appears to me as a collection of widgets that come with WordPress. Adding the ‘cat’ parameter probably changes the ‘Archives’ widget and I expect it to work fine. But since you’re editing a core file be careful that updating WordPress doesn’t overwrite your changes!
Selsobesy 8-04-2009 (10:06)
mm. thank you..
Dorothea Schäfer 9-04-2009 (0:13)
Great!
Theank you very much.
Jukka 18-04-2009 (23:10)
Hi!
I have a small problem with the plugin. It works like a charm with current month, but not for earlier months.
I have two categories. If there aren’t any posts in category 1 for say January, the month won’t show on the archive list, so that’s fine. But when I call posts from catgory 1 and there are some, the plugin also shows posts from category 2 for that month.
Do you have any idea why this is happening?
Rob Schlüter 19-04-2009 (16:53)
@jukka: it’s a bug. I’ve resolved the problem and updated the plugin. The new version (1.4b) is available for download.
In this version the support for multiple calls to wp_get_archives(), with and without ‘cat’ parameter, is removed. This feature was the cause of the bug.
Jukka 20-04-2009 (7:49)
Thank man! Works great now.
Karl 21-04-2009 (13:28)
Hi there,
Thanks for the plugin, just what I needed! Agree with posters above, would be great if this was simply built into WP core, pretty logical call.
Another related issue I’ve never been able to solve, is giving the currently viewed archive a current-class – is this anything that could be built into your plugin? Then one can use CSS to list which month is being viewed.
Karl 14-12-2009 (17:37)
Just came across some code in the WP forums about creating a function to exclude one or more categories from the wp_get_archives – http://wordpress.org/support/topic/292286. This might be enough for those just wanting to exclude a category from a yearly view.
Vince Brown 21-04-2009 (22:16)
Thanks mate
Rob Schlüter 22-04-2009 (11:55)
@karl, marking the currently viewed archive looked like a nice challenge so I did some testing and came up with a basic solution.
But the plugin parses the generated HTML for the archives and that’s not something I like. I want to see if I can come up with a better solution and publish it as part of this plugin or as a separate one.
Saeid Zebardast 24-04-2009 (15:45)
Thank you
Its useful.
Stereo Interactive 25-04-2009 (18:47)
Thank you Rob, it is so nice of you to share this with us all.
Karl 27-04-2009 (9:24)
@Rob,
Thanks for looking into the highlighting issue – would be interesting to hear what you come up with!
Eric Curtis 7-05-2009 (2:21)
Just wanted to say thank you for this plug-in. It was just what I needed for my last project.
FYI, I found a conflict with this and WP-Security Scan. When both were active your plug-ins functionality was broken.
Cheers.
Cisco 15-05-2009 (10:43)
Hello, thanks for your plugin,
can you add the parameter “child_of” ? Because when I type the global category, there’s no list.
june 18-05-2009 (3:00)
I dropped this my plugins directly and its not showing up in my admin interface. I’ve installed other plugins without a problem. Using 2.7.1
Rob Schlüter 18-05-2009 (20:05)
Thanks for the responses. Perhaps a small forum would be easier for communicating issues and new features then these comments…
Brad 21-05-2009 (22:16)
This seems to be the only solution for excluding cats from get archives, i cant get it to work though sadly,
The archive list goes blank when i add cat=-2 but works when i remove it
Im using 2.7.1
pirkka 22-05-2009 (16:15)
I have the same problem.
Scott 28-05-2009 (11:31)
Just wanted to say thanks for the plugin, works great for me on 2.7.1.
Ash Haque 6-06-2009 (8:14)
Thank you!
This was exactly what I was looking for, works great
Matt 11-06-2009 (14:22)
I’m having trouble as I have this: domain…./2009/05/?cat=4 when I click it though, it fwds to the url of the category: domain…category/the-category/ and it displays all the posts for all the months, rather than the posts for just may. Any ideas?
Rob Schlüter 12-06-2009 (13:01)
@matt: perhaps it helps to disable canonical URL redirect. You can do this on the Settings > Kwebble page.
Note that this influences other URL’s handling also, see the linked page for more info.
james 19-07-2009 (7:17)
hi all, thanks for this plugin and posts:
the concept of this plugin is exactly what i need, but i am not understanding all the comments on this post.
i installed the plugin and have the line :
Archives
in my sidebar.php page, but when i view my wordpress page, the archive widget still shows all cat posts, not just cat=5.
Am i missing something ?
thanks
p.s. i am rockin WP ver 2.7.1
Rob Schlüter 19-07-2009 (13:01)
That’s correct, the default Archives widget doesn’t ‘know’ my plugin and doesn’t offer an option to select a category. The calls in sidebar.php are probably only used when the theme is used in a older WordPress installation without current widget support.
I was working on a new version of my plugin that includes an improved Archives widget. But while I was finishing it, WP 2.8 was released and the widget support has completely changed. There are now 3 or 4 ways to build widgets and because of these frequent changes to the WP core I haven’t decided yet about releasing a new plugin version, and supporting it.
David 3-12-2010 (21:12)
I am using WordPress 2.8.4
I think I amy be having this same problem. I can use your plugin just fine on my “News” page. The sidebar only displays the category or archives that I choose. However, once you click on a month in that sidebar, and it displays the archives for that month, the sidebar reverts back to showing all the categories (for News, Events, Press Releases, etc.).
Is there a way to change this?
james 19-07-2009 (7:24)
p.p.s
I meant that i have wordpress version 2.8.1
not
2.7.1
thanks
jimmy 21-07-2009 (11:52)
great plugin, but it seems not work in wp 2.8.2. please help. thanks.
Rob Schlüter 21-07-2009 (20:41)
With a fresh install of WP 2.8.2 plus my plugin and adding 2 testing posts over 2 categories it works fine. Can you give some more details on your results?
jimmy 22-07-2009 (4:07)
i just put this code in, but it show nothing.
jimmy 23-07-2009 (9:11)
maybe it conflict with other plugins, any suggestion how to check it conflict with others? please advice.
Rob Schlüter 23-07-2009 (11:45)
If you turn off all plugins and activate them one by one and each time check to see if it works you may be able to find the plugin that has a conflict.
taro 23-07-2009 (3:46)
php5&mysql5?
Leandro 23-07-2009 (17:02)
Thank you, I’ve just installed it and worked like a charm!
Jerry 24-07-2009 (19:01)
This is just an awesome tool!
Thanks
bira 29-07-2009 (22:31)
It worked fine for me in wp 2.8.1 after I’d deactivate the WP Securityscan 2.7.1
richy 30-07-2009 (9:36)
Thanks a lot, you made my day
Michael Cairns 5-08-2009 (11:39)
Hmmm, I can’t seem to get the plugin to work for more than one month.
If you look at the archives here: http://www.lemonroe.com.au/blog/ only August 2009 allows the plugin. I have deactivated all my other plugins but no luck.
Any help would be great.
I am using 2.8.3
Michael Cairns 6-08-2009 (2:00)
Downgraded to 2.8.1 but still no love….any help?
Rob Schlüter 8-08-2009 (10:19)
Perhaps you also use the WP Securityscan plugin? Others reported that using both plugins may give problems?
jimmy 12-08-2009 (4:10)
yes. please check that i also have this problem before.
tobi 18-08-2009 (11:12)
i had the same problem but figured out that i downloaded version 1.4a from the end of this article.
grab the plugin from the download link in the beginning of the article under “installation”. this is verion 1.4b and the problem is solved…
Rob Schlüter 18-08-2009 (11:35)
I added a warning to the list of older versions to help people notice they are not downloading the current version and prevent problems.
tobi 18-08-2009 (14:04)
thanks.
by the way: your plugin is working on my current wordpress 2.8.4
great job.
Joss 10-09-2009 (0:15)
*Slaps Forehead*
I accidentally originally downloaded the previous 1.4 version of your plugin.
The current version works fine
Sorry for the hassle – but at least now you know it’s tested with WP 2.8.4!
Best of luck and thanks for your help.
jimmy 11-08-2009 (10:48)
i cannot get the cat parameter in the archive, anything wrong?
Rob Schlüter 11-08-2009 (11:06)
What code do you use to show the list of archives?
jimmy 12-08-2009 (4:10)
i just put this code in category.php ,thanks.
Jeremy 17-08-2009 (4:09)
This is awesome and just what I was looking for…the only problem I have is that I am using this to display a navigation pane of links to archives..whenever I click on the month I wish to see it goes where it should, but the problem is that the navigation pane then will turn into the same old junk where if I click on a month again it navigates away from the specific category and back to an archive of every post on the site.
Do you know of any way to fix this? Any help is appreciated…I guess what would really need to happen is changing (in archive.php):
to or having some way to fetch the category id from the url…I dont really know and am a total noob at this stuff…
Thanks for a great fix, anyhow!
Geoff 17-08-2009 (22:16)
Great plugin. Thanks for your work.
Anja 3-09-2009 (17:33)
It doesn’t work for me.
It’s like there wasn’t a plugin / change. Bah, it was exactly what i was looking for
Rob Schlüter 3-09-2009 (20:38)
A few checks: to the URL of your blog.
- the plugin must be activated.
- if that’s done the ‘Settings’ menu must include a choice called ‘Kwebble’.
- add a ‘cat’ parameter to the wp_get_archives() call, using an existing category? You can get a page with the posts of a category by adding ?cat=
Anja 3-09-2009 (22:23)
hey, thanks for the quick response.
i didn’t get the last point?!
yes, it is activated, i see the kwebble in the settings. i’ve added to the sidebar. the category which i’d like to have a archive of has the ID 16. i replaced this with the default get_archives in the sidebar?
here’s the website: http://www.brokenstars.org/ the archives are a mess right now. but “september 2009″ should be showing the entries of diary only. my whole site is build up with categories.
am i doing completely wrong?
thanks
Rob Schlüter 8-09-2009 (22:00)
Did you try to deactivate the canonical URL redirection? The plugin gives the option to do this. Note that it influences URL handling, so it may give other unwanted side effects.
http://www.brokenstars.org/?cat=16 shows the items of category 16. http://www.brokenstars.org/2009/09/ shows the archive for september. But http://www.brokenstars.org/2009/09/?cat=16 doesn’t combine the criteria. Instead you are redirected to a page with the category.
PS.
sorry you had to wait, I missed your comment because it was held in moderation.
Joss 9-09-2009 (10:48)
Hi Rob,
This plugin looks like exactly what we’ve been looking for for a while
)
I’ve activated it and want to show monthly archives from just the blog, excluding all the other types of post the site uses.
It works like a charm for the first entry in the archive, but after that, reverts to the regular Wordpress style “Let’s give them everything” style afterwards.
So, the first (current) month, the link looks like this:
/2009/09/?cat=4type=monthly
which is great.
For all the ones afterwards, it’s back to
/2009/08/
/2009/07/
etc.
Is there a way to fix this? Something I’ve done wrong maybe?
Many thanks!
Rob Schlüter 9-09-2009 (12:09)
Are these URL’s from the generated list of archives on 1 page? If not, be sure to the add the cat parameter in each template of the theme that shows such a archive list.
Joss 9-09-2009 (13:15)
Thanks for your quick reply!
Yup, they’re from the same generated list. The code looks something like this:
wp_get_archives(’cat=4&type=monthly&limit=6&format=custom&before=&after=’);
…with the output coming out as I posted above – the first link is the correct format, but the following generated links are just the normal archive format (eg. it looks like the plugin hasn’t touched them)
Any advice?
Thanks!
Rob Schlüter 9-09-2009 (21:23)
Ok, just did a fresh install of 2.8.4, added my plugin and some posts. The generated URL’s in the list of archives look like these:
/blog/?m=200909&cat=3
/blog/?m=200907&cat=3
and work ok.
Perhaps a different plugin interferes? You coulkd deactivate other plugins, activate them one by one and see when the problem occurs.
Joss 10-09-2009 (0:09)
That’s strange!
I deactivated all other plugins, also tried removing various arguments from the get_archives string. I’m still getting the following output in my list of archives:
example.com/2009/09/?cat=4
example.com/2009/06/
example.com/2009/07/
I wonder why it’s not appending the ?cat=4 to the links after the first?
I’ll try deleting and reinstalling the plugin.
Joss 10-09-2009 (0:16)
*Slaps Forehead*
I accidentally originally downloaded the previous 1.4 version of your plugin.
The current version works fine
Sorry for the hassle – but at least now you know it’s tested with WP 2.8.4!
Best of luck and thanks for your help.
(ps. apology for double post of this comment, posted in the wrong place above.)
Rob Schlüter 10-09-2009 (21:00)
Ok, glad to know it’s not a new bug.
Joss 9-09-2009 (13:17)
Ps. I’m running the latest Wordpress, 2.8.4.
erim 21-10-2009 (23:29)
Hi,
Thanks for the plugin. It’s just what I need, but I can’t seem to get it working. I get a SQL error in my logs when I add the ‘cat=31′ parameter. Here’s the SQL returned:
SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM wp_posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND wp_posts.ID IN (SELECT DISTINCT ID FROM wp_posts JOIN wp_term_relationships term_relationships ON term_relationships.object_id = wp_posts.ID JOIN wp_term_taxonomy term_taxonomy ON term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id WHERE term_taxonomy.taxonomy = ‘category’ AND term_taxonomy.term_id IN (31)) GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, wp_get_archives
I’m running Wordpress 2.8.5.
Thanks.
erim 22-10-2009 (2:43)
Oops, I messed that up. Here’s the SQL returned by wp_get_archives() function in general-template.php. It errors if I paste it into phpMyAdmin. Unfortunately, the host this site is running on is using mySQL 4.0.14 and PHP 4.4.1, which could very easily be the problem.
SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM wp_posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND wp_posts.ID IN (SELECT DISTINCT ID FROM wp_posts JOIN wp_term_relationships term_relationships ON term_relationships.object_id = wp_posts.ID JOIN wp_term_taxonomy term_taxonomy ON term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id WHERE term_taxonomy.taxonomy = ‘category’ AND term_taxonomy.term_id IN (31)) GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
erim 22-10-2009 (18:48)
It occurred to me to try this SQL in phpMyAdmin running on a more recent version of mySQL/PHP (4.1.22/5.2.9) and it works. Also, I can run both the outer statement and the nested select separately on the original server and they work. It seems to be just the combination of the two on the older mySQL version that’s causing the problem. Maybe it’s the join?
If anybody has any ideas, they’d be most appreciated. I really need this plugin, and I can’t upgrade the server.
Thanks.
Rob Schlüter 22-10-2009 (19:42)
I’ll have to do some investigating to see if I can fix it.
erim 26-10-2009 (20:49)
Thanks Rob. I contacted the hosting company too, just to see if they can do the upgrade. It’s kind of ridiculous they’re running mySQL 4.0.14, released in 2003. Maybe they’ll just upgrade and solve the problem.
Rob Schlüter 26-10-2009 (23:17)
Just did a test install of WP 2.8.5 and it seems to work fine. But my server runs MySQL 5.1.30.
In the older MySQL documentation I read that before version 4.1 support for subqueries was limited. I guess that the cause of the problem.
erim 27-10-2009 (18:51)
Yeah, that’s about what I figured. Thanks for your help though Rob. I think I can get the host to upgrade.
Thanks again.
ryo 2-11-2009 (4:40)
Hello,
I have the exact same problem. It was working prefectly on my MacBook test environment, but it stopped working on a virtual host server running old MySQL 4.0.24…
Is there any possibility that you make the script backword compatible with older MySQL?
By the way, thank you very much for your great work! So far yours is the best out there.
Rob Schlüter 4-11-2009 (13:09)
I’ve done a quick test with a version that doesn’t need the subquery in the SQL and it looks like it might work.
But I don’t know if that’s enough to make it run on the MySQL version you use. The best solution would be to support the same database version WordPress supports, which is 4.0 or greater. But I’ll see what I can do.
Gary 22-10-2009 (18:22)
Hi, has anyone gotten this to work in Wordpress 2.8.5? Thanks!
Rob Schlüter 26-10-2009 (23:21)
Can you explain the problems, I’m not aware of any.
Gary 28-10-2009 (3:10)
In theory, the following link should take me to the archives for that category for 10/2009:
http://30thx365.wonggawei.com/2009/10/?cat=28
However, the URL always changes to the category archive URL:
http://30thx365.wonggawei.com/category/take-2/
Any thoughts? The only other active plugin is Askimet.
victor 25-10-2009 (18:05)
Hello,
I’ve noticed something interesting. For testing purposes I’ve published two posts in different categories with the date set in the past ex: 12 november 2006. Well, for that month it shows posts from both categories. Why is that?
Victor
Rob Schlüter 26-10-2009 (23:33)
Please compare the URL in the list of archives and on the page with the archive for november 2006. They should be equal and both include a cat parameter.
If the archive page doesn’t, WP redirects to a different URL and looses the category selection. Disabling the ‘canonical URLs’ function may solve this problem, but it might conflict with other functionality on your site, so you’ll need to test.
Erik N 27-10-2009 (0:06)
I’m having issues with version 2.8.5 as well. I can activate the plugin and all, but when I add the &cat=-14 to the archive code, it doesn’t show any posts at all in the drop-down, just the “Select a Post” text. When I take the code out again, it shows all of my posts in the drop-down archive again. I’ve tried turning off all of my plugins and nothing seems to work! Here’s the code I’m using:
Select a page!
Current:
Rob Schlüter 27-10-2009 (22:37)
Somehow the comment system seems to mess up the code. Could you only post the parameter string passed to wp_get_archives? I’m curious what type of archive you want to show.
Erik N 27-10-2009 (0:07)
“Select a page!
Current: “
awesomerobot 6-11-2009 (16:58)
Interesting little something I found out: the popular plug-in “WP Security Scan” interferes, and it won’t list any archives as long as it’s activated. Not a huge issue, but something to note for anyone having issues out there.
Rob Schlüter 6-11-2009 (22:06)
previously others have reported problems when that plugin is used. To reproduce them I installed the plugin. After that I couldn’t access the blog or admin pages anymore and gave up.
Vishnu 21-12-2009 (15:07)
Hai,
Thanks for this plugin…
The problem is when i activated this plugin it works well and it shows the particular category i want to show But when i activated the permalink settings(/%postname%/) it works on and it shows the archive list in monthly type for partiicular category but when i navigate through that archive list it shows the post of other categories… abviously it works correctly when i deactivate permalinks …
The blog was in windows server 2008, wordpress ver 2.8.6, i installed a plugin for SEO url as it is in IIS ….
Please help any one …
Thanks in advance..
Tom 23-12-2009 (17:40)
I’m having the same problem as Vishnu. Seems be to an issue with custom permalinks. Anyone know of a fix for this?
Tom 23-12-2009 (17:49)
Actually, I fixed it by “disabling canonical URLs”. Disregard!
Barry 11-01-2010 (22:25)
Hello,
I’m using your *AWSM* plugin with WP 2.9 and it’s working like a champ.
I thought I would share a few notes for those who could use clarification:
I am displaying category archives in a custom template. I created a custom file called category-6.php for this purpose. (The category I am showing is ID=6.) The Wordpress template hierarchy automatically finds this.
Also, I had to hard-code the entire drop-down format in my sidebar. It would not work with a simple call of wp_get_archives(’format=option&cat=6′). Since I am using a widgetized sidebar, I put the code after the loop that goes out to the dynamic sidebar.
Looks like this:
(I don’t think the type=monthly param is necessary but I left it in for some reason.)
Rob / Kwebble, thank you for continuing to support this useful plugin. I would be ecstatic if you decided to create a widget version.
Best,
Barry
Rob Schlüter 12-01-2010 (9:54)
When I noticed the Archives widget that comes with WordPress I started coding a version of my plugin with an improved widget. I got it working but just before I finished it a new WordPress version was released which changed the API to create plugins or widgets, I don’t know which one. There were already 2 API’s, now a 3rd was added, without stating what was to happen with the other versions.
Since it was unclear to me what was going to happen I decided not to finish and release it.
To me as a developer it’s like the platform I’m developing on just changes without prior notice. That’s something I don’t like because I can’t be sure if my code will keep functioning correctly in the future. Since then I’ve frozen further development.
Barry 11-01-2010 (22:27)
Claude Schneider 24-01-2010 (19:26)
Thanks for the great plugin. I found that the URLs generated aren’t interpreted correctly by WordPress (I’m using MU 2.8.5).
I’ve got my categories working on this URL structure: /category/slug-name/ and /category/slug-name/page/2/ etc.
The URL generated by the plugin for a monthly archive is simply /yyyy/mm/?cat=3 which WordPress just redirected to /category/slug-name/ – not doing much for showing the month’s archive.
I changed one of your functions, so that the URL generated is: /slug-name/yyyy/mm/ – this now works fine.
Not sure if this is a problem only because of the way I’ve set up this WP site, but hope it may be useful for anyone else encountering the same problem.
thanks,
Claude
function kwebble_archive_link_for_category($url){
global $kwebble_getarchives_data;
if (isset($kwebble_getarchives_data['cat']))
{
$cat_object = get_category($kwebble_getarchives_data['cat']);
$cat_slug = $cat_object->slug;
$blog_url = get_bloginfo(’url’);
$url = str_replace($blog_url, $blog_url.”/”.$cat_slug, $url);
}
return $url;
}
Dada 1-02-2010 (14:06)
Thanks so much
Works perfectly!
Kate 22-03-2010 (3:23)
Hi,
I am having some problems with this plugin.
In the category menu, my urls look like this: /2010/03/?cat=1, however, for every page that I select, it just goes back to the main archive page for the category, so there is nothing much happening.
I disabled canconical urls, but this didn’t seem to do anything.
Any ideas?
Thank you!
Kate
Kate 22-03-2010 (3:28)
Oooops, forget the last one. I was using a category template, with the category ID already in the loop. Works fine now. Thanks!
Kate
Mike 29-03-2010 (9:47)
Hi!
I have the same problem as Kate, but a I don’t know how to fix it.
Rob Schlüter 29-03-2010 (11:28)
Perhaps some other plugin is messing up the URL handling, assuming you’ve tried disabling the use of canonical urls.
Mike 31-03-2010 (12:55)
Mmmmm…. If I’m using a category template, with the category ID in the loop… ¿what can I do to solve my problem?
Simon 23-04-2010 (17:00)
Fantastic plugin. I have no idea why this functionality isn’t built into WordPress. Just one question. Can anyone tell me how to use this to automatically show archives of the current category?
Ari Salomon 4-05-2010 (19:50)
i am confirming this works with wp 2.9.2
great job! thanks!
Jocelyn 17-05-2010 (6:15)
Great Plugin. Is there any way to have cat=-3 remove that category and all sub categories?
nosaint 30-08-2010 (17:01)
simply add cat=-321,-322,-333 (the ids of all subcategories)
Alex Kuznetsof 29-06-2010 (10:11)
God bless you
wordpress 3.0 WORKS!!!
Lynn Wallenstein 2-07-2010 (21:49)
Thanks for the great plugin. Any possibility for an option where AND is actually AND and not IN? I need to get something where it gets me the posts ONLY if they are in two categories (or more).
Thanks for the awesome work!
pirmin 8-07-2010 (16:13)
perfect. thanks a lot!
Arpita 6-08-2010 (6:21)
I am not able to solve issues for this plugin with versionm 3.0.1, but I used this same functionality using query_post function.
Luke Archer 23-08-2010 (9:06)
Ideally I would like my archive urls like this: mysite.com/cat/year/month/ so the cat replaces the ?cat=x that normally appears.
Is there any way to achieve this?
Thank you
Michelle 20-09-2010 (18:21)
Hello,
Thanks for the plugin! Just downloaded and installed. I added it to 3 category pages. It pulls the correct list of months for the archive, but only the first month in each archive list has the “cat=3″ tag on the link.
Example, first link in the list is “?m=20100&cat=3″ but the rest of the links in the list have only the month, such as “?m=20200″.
My code is simply:
Have I done somehting wrong or is there a problem with the loop code?
Thanks for your help!
Michelle 20-09-2010 (18:23)
^^I guess the code didn’t show up but it is exactly what is listed in the first example above, simply cat = 3.
Debbie 6-10-2010 (18:24)
This is a great plugin, thank you so much.
I too found that when WP Security Scan is active, no results will show. Not a big deal but maybe that will help someone else.
Jes 1-11-2010 (11:16)
After searching for quite a while, this is exactly what I needed. Thank you!
Mark McLaren 16-11-2010 (8:07)
Thank you very much for your work on this plugin. I was going nuts trying to figure this out! I don’t understand why this is not in WordPress core for wp_get_archives() Kudos to you! The WordPress community rocks!
Tobia Scandolara 22-11-2010 (15:04)
I use Wordpress 3.0 but this plugin doesn’t work. Why?
I tried too disable the canonical url
Webdesigner 9-02-2011 (19:33)
Thanks for that great Plugin. It works perfectly for me.
For more custumization you can use it like this:
‘monthly’,
‘cat’ => ‘1′,
‘mcat’ => true,
‘limit’ => ”,
‘format’ => ‘custom’,
‘before’ => ”,
‘after’ => ”,
’show_post_count’ => false,
‘echo’ => 1 );
?>
Best Regards,
Webdesigner
Vermont WordPress 24-03-2011 (14:43)
Many thanks, finding this saved me a lot of work.
Kurt 27-04-2011 (7:48)
Hi!
Thank you very much for such a great plugin. I have a problem getting it to work 100% with my website. Currently, I use the parameters postbypost and 10, the latter one to limit the number of entries listed.
However, with these current parameters, I can’t seem to get the cat=-20 work. Any ideas?
Katie @ women magazine 12-05-2011 (9:19)
Using plugin for such simple task is not good, you can directly call a filter to include or exclude a particular category from wp_get_archives functions. In your fuctions.php file write this
add_filter( ‘getarchives_where’, ‘customarchives_where’ );
add_filter( ‘getarchives_join’, ‘customarchives_join’ );
function customarchives_join( $x ) {
global $wpdb;
return $x . ” INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)”;
}
function customarchives_where( $x ) {
global $wpdb;
$exclude = ‘827,828′; // category id to exclude
return $x . ” AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)”;
}
To include only specific categories do this
add_filter( ‘getarchives_where’, ‘customarchives_where’ );
add_filter( ‘getarchives_join’, ‘customarchives_join’ );
function customarchives_join( $x ) {
global $wpdb;
return $x . ” INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)”;
}
function customarchives_where( $x ) {
global $wpdb;
$includes= ‘829′; // category id to include
return $x . ” AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->term_taxonomy.term_id NOT IN ($includes)”;
}
Anton 6-06-2011 (23:37)
Katie, what about the URLs the archive links lead to?
That’s the main thing the plugin solved for me. I did the filters for where and join too but URLs kept fucking up.
OP, Thanks a lot for this plugin. I might think of extending it in the near future and will contact you if i do so.
I confirm that it works on WP 3.1.3. (if you turn the canonical URLs off).