Kwebble : Blog

  • Archives for a category WordPress plugin

    Gepubliceerd op 15 augustus 2007 in Programming. 166 reacties

    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

    1. Download the plugin zip file and unzip the file in a temporary directory.
    2. Put the kwebble_archives_by_cat.php file in your WordPress plugin directory:
      <your wordpress dir>/wp-content/plugins
    3. Activate the plugin ‘Archives for a category’ on the Plugin Management page of the WordPress administration panel.
    4. 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.
    • php
    • plugin
    • wordpress

    147 Reacties

    1. Queenvictoria 4-10-2007 (22:08)

      Avatar

      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;
      }

      Reageren
    2. Queenvictoria 4-10-2007 (22:14)

      Avatar

      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;
      }

      Reageren
    3. Rob Schlüter 5-10-2007 (20:00)

      Avatar

      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.

      Reageren
    4. Mike 31-10-2007 (20:22)

      Avatar

      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″)

      Reageren
    5. Rob Schlüter 1-11-2007 (9:28)

      Avatar

      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.

      Reageren
    6. jay 20-11-2007 (16:11)

      Avatar

      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

      Reageren
    7. Rob Schlüter 21-11-2007 (21:58)

      Avatar

      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.

      Reageren
    8. Rob Schlüter 23-11-2007 (23:30)

      Avatar

      A new version (1.2) with WordPress 2.3 support is now available.

      Reageren
    9. stephen 29-12-2007 (10:12)

      Avatar

      This is really great, but I was wondering if there was a way to show multiple categories.

      Reageren
    10. Rob Schlüter 30-12-2007 (23:57)

      Avatar

      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.

      Reageren
    11. steve 1-01-2008 (23:24)

      Avatar

      That would be great!

      Reageren
    12. Rob Schlüter 6-01-2008 (14:29)

      Avatar

      Just updated the plugin to version 1.3, which adds support for multiple categories.

      Reageren
    13. jack 22-01-2008 (2:32)

      Avatar

      exactly what I needed, thanks!

      Reageren
    14. Tony 23-01-2008 (4:34)

      Avatar

      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!

      Reageren
    15. cj 25-02-2008 (23:33)

      Avatar

      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

      Reageren
    16. Rob Schlüter 26-02-2008 (13:19)

      Avatar

      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 .

      Reageren
    17. slambert 11-03-2008 (6:46)

      Avatar

      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.

      Reageren
    18. Rob Schlüter 14-03-2008 (21:37)

      Avatar

      @slambert: does the parameter show_post_count you can use with wp_get_archives do what you need?

      Reageren
    19. slambert 16-03-2008 (23:55)

      Avatar

      @rob Schülter: yes and no. That’s the functionality, but I still want to filter it by category. Make sense?

      Reageren
    20. Zef 13-04-2008 (0:41)

      Avatar

      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!

      Reageren
    21. Tom 28-04-2008 (20:07)

      Avatar

      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.

      Reageren
    22. Rob Schlüter 28-04-2008 (22:01)

      Avatar

      I will investigate what’s the reason 2.5 breaks the plugin.

      Reageren
    23. tom 20-05-2008 (14:37)

      Avatar

      @rob: I was wrong. It IS in fact working in Wordpress 2.5. Sorry for the confusion.

      Reageren
    24. Chi 21-05-2008 (17:15)

      Avatar

      Hi.. Nice plugin.. Unfortunately, it isn’t retreiving children category posts.. Pls help!

      Reageren
    25. Rob Schlüter 22-05-2008 (8:12)

      Avatar

      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.

      Reageren
    26. Jeff 3-07-2008 (13:13)

      Avatar

      Just wanted to say thank you. Really appreciate the work :)

      Reageren
    27. Nicole 16-07-2008 (0:42)

      Avatar

      Hi there,
      great plugin and easy to use!
      Just wondering, I want to Archive via Year, not month.. can this plugin do that?

      Reageren
    28. Rob Schlüter 16-07-2008 (8:17)

      Avatar

      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'); ?>

      Reageren
    29. ann 15-08-2008 (20:08)

      Avatar

      thanks! this saved me tons of headache!

      Reageren
    30. Steve Meisner 2-09-2008 (20:04)

      Avatar

      Thanks, it works great in 2.6.1.

      Reageren
    31. Paul 8-10-2008 (11:01)

      Avatar

      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 ?

      Reageren
    32. Rob Schlüter 8-10-2008 (12:39)

      Avatar

      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.

      Reageren
    33. Paul 8-10-2008 (12:48)

      Avatar

      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.

      Reageren
    34. Carl-Johan 20-12-2008 (0:19)

      Avatar

      Great plugin! This should really become a basic function in wordpress. Maybe you could submit it to them.

      Reageren
    35. Rob Schlüter 20-12-2008 (14:08)

      Avatar

      @Carl-Johan in the current situation this plugin conflicts with the canonical URLs feature. That should be resolved to be included, I expect.
      But surely I agree :-) , it would be a useful addition.

      Reageren
    36. anders 21-01-2009 (12:36)

      Avatar

      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

      Reageren
    37. Rob Schlüter 21-01-2009 (13:36)

      Avatar

      @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.

      Reageren
    38. anders 23-01-2009 (9:02)

      Avatar

      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?

      Reageren
    39. Russ 2-02-2009 (19:45)

      Avatar

      Great plugin! It did EXACTLY what I needed it to. Super-easy and brilliant!

      Reageren
    40. luke 3-02-2009 (20:00)

      Avatar

      thanks!
      exactly what i need…..

      Reageren
    41. Susan 9-02-2009 (19:07)

      Avatar

      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!

      Reageren
    42. Susan 9-02-2009 (19:09)

      Avatar

      search term didn’t show up. It was

      Reageren
    43. Susan 9-02-2009 (19:10)

      Avatar

      one more try
      “”

      Reageren
    44. Jonathan 16-02-2009 (2:42)

      Avatar

      Would also love it if this would allow for category exclusion :) .

      Reageren
    45. Sarah 17-02-2009 (11:33)

      Avatar

      I wish this was 2.7 compatible.
      Is there any chance you’ll update it?
      Please?

      Reageren
    46. Rob Schlüter 17-02-2009 (14:31)

      Avatar

      @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?

      Reageren
    47. damien 20-02-2009 (13:04)

      Avatar

      @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)?

      Reageren
    48. Rob Schlüter 20-02-2009 (23:03)

      Avatar

      Sorry Damien, at the moment only posts from the selected categories, no AND/OR/EXCLUDE.

      Reageren
    49. Rob Schlüter 22-02-2009 (22:55)

      Avatar

      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.

      Reageren
    50. damien 23-02-2009 (12:59)

      Avatar

      How to use your plugin with the tags?
      Thank you for updating!

      Reageren
    51. Rob Schlüter 23-02-2009 (13:44)

      Avatar

      @damien: see ‘Examples’ on this page for the syntax you have to use.

      Reageren
    52. peach 3-03-2009 (23:38)

      Avatar

      fyi – works great in wp 2.7.1. thanks!

      Reageren
    53. Vlad 17-03-2009 (8:30)

      Avatar

      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.

      Reageren
    54. wp 23-03-2009 (4:06)

      Avatar

      this plugin is a lifesaver. thanks!

      Reageren
    55. danjothebanjo 25-03-2009 (17:58)

      Avatar

      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.

      Reageren
    56. Rob Schlüter 25-03-2009 (22:10)

      Avatar

      @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.

      Reageren
    57. danjothebanjo 26-03-2009 (12:25)

      Avatar

      thanks Rob, I actually used is_date() in a conditional statement in my category template to get the template looking right – thanks again

      Reageren
    58. Rob Schlüter 27-03-2009 (13:58)

      Avatar

      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

      Reageren
    59. Becky 27-03-2009 (23:56)

      Avatar

      It’s not working for me. I used and nothing is showing up. What am i missing?

      Reageren
    60. Rob Schlüter 28-03-2009 (12:25)

      Avatar

      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?

      Reageren
    61. bill 3-04-2009 (23:23)

      Avatar

      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.

      Reageren
    62. Rob Schlüter 5-04-2009 (19:06)

      Avatar

      @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!

      Reageren
    63. Selsobesy 8-04-2009 (10:06)

      Avatar

      mm. thank you..

      Reageren
    64. Dorothea Schäfer 9-04-2009 (0:13)

      Avatar

      Great!
      Theank you very much.

      Reageren
    65. Jukka 18-04-2009 (23:10)

      Avatar

      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?

      Reageren
    66. Rob Schlüter 19-04-2009 (16:53)

      Avatar

      @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.

      Reageren
    67. Jukka 20-04-2009 (7:49)

      Avatar

      Thank man! Works great now.

      Reageren
    68. Karl 21-04-2009 (13:28)

      Avatar

      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.

      Reageren
    69. Vince Brown 21-04-2009 (22:16)

      Avatar

      Thanks mate

      Reageren
    70. Rob Schlüter 22-04-2009 (11:55)

      Avatar

      @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.

      Reageren
    71. Saeid Zebardast 24-04-2009 (15:45)

      Avatar

      Thank you :)
      Its useful.

      Reageren
    72. Stereo Interactive 25-04-2009 (18:47)

      Avatar

      Thank you Rob, it is so nice of you to share this with us all.

      Reageren
    73. Karl 27-04-2009 (9:24)

      Avatar

      @Rob,

      Thanks for looking into the highlighting issue – would be interesting to hear what you come up with!

      Reageren
    74. Eric Curtis 7-05-2009 (2:21)

      Avatar

      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.

      Reageren
    75. Cisco 15-05-2009 (10:43)

      Avatar

      Hello, thanks for your plugin,
      can you add the parameter “child_of” ? Because when I type the global category, there’s no list.

      Reageren
    76. june 18-05-2009 (3:00)

      Avatar

      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

      Reageren
    77. Rob Schlüter 18-05-2009 (20:05)

      Avatar

      Thanks for the responses. Perhaps a small forum would be easier for communicating issues and new features then these comments…

      Reageren
    78. Brad 21-05-2009 (22:16)

      Avatar

      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

      Reageren
    79. pirkka 22-05-2009 (16:15)

      Avatar

      I have the same problem.

      Reageren
    80. Scott 28-05-2009 (11:31)

      Avatar

      Just wanted to say thanks for the plugin, works great for me on 2.7.1.

      Reageren
    81. Ash Haque 6-06-2009 (8:14)

      Avatar

      Thank you!
      This was exactly what I was looking for, works great

      Reageren
    82. Matt 11-06-2009 (14:22)

      Avatar

      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?

      Reageren
    83. Rob Schlüter 12-06-2009 (13:01)

      Avatar

      @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.

      Reageren
    84. james 19-07-2009 (7:17)

      Avatar

      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

      Reageren
      1. Rob Schlüter 19-07-2009 (13:01)

        Avatar

        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.

        Reageren
    85. james 19-07-2009 (7:24)

      Avatar

      p.p.s
      I meant that i have wordpress version 2.8.1

      not

      2.7.1

      thanks

      Reageren
    86. jimmy 21-07-2009 (11:52)

      Avatar

      great plugin, but it seems not work in wp 2.8.2. please help. thanks.

      Reageren
      1. Rob Schlüter 21-07-2009 (20:41)

        Avatar

        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?

        Reageren
        1. jimmy 22-07-2009 (4:07)

          Avatar

          i just put this code in, but it show nothing.

          Reageren
        2. jimmy 23-07-2009 (9:11)

          Avatar

          maybe it conflict with other plugins, any suggestion how to check it conflict with others? please advice.

          Reageren
          1. Rob Schlüter 23-07-2009 (11:45)

            Avatar

            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.

            Reageren
    87. taro 23-07-2009 (3:46)

      Avatar

      php5&mysql5?

      Reageren
    88. Leandro 23-07-2009 (17:02)

      Avatar

      Thank you, I’ve just installed it and worked like a charm!

      Reageren
    89. Jerry 24-07-2009 (19:01)

      Avatar

      This is just an awesome tool!

      Thanks

      Reageren
    90. bira 29-07-2009 (22:31)

      Avatar

      It worked fine for me in wp 2.8.1 after I’d deactivate the WP Securityscan 2.7.1

      Reageren
    91. richy 30-07-2009 (9:36)

      Avatar

      Thanks a lot, you made my day :-)

      Reageren
    92. Michael Cairns 5-08-2009 (11:39)

      Avatar

      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

      Reageren
      1. Michael Cairns 6-08-2009 (2:00)

        Avatar

        Downgraded to 2.8.1 but still no love….any help?

        Reageren
        1. Rob Schlüter 8-08-2009 (10:19)

          Avatar

          Perhaps you also use the WP Securityscan plugin? Others reported that using both plugins may give problems?

          Reageren
          1. jimmy 12-08-2009 (4:10)

            Avatar

            yes. please check that i also have this problem before.

            Reageren
            1. tobi 18-08-2009 (11:12)

              Avatar

              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…

              Reageren
              1. Rob Schlüter 18-08-2009 (11:35)

                Avatar

                I added a warning to the list of older versions to help people notice they are not downloading the current version and prevent problems.

                Reageren
                1. tobi 18-08-2009 (14:04)

                  Avatar

                  thanks.
                  by the way: your plugin is working on my current wordpress 2.8.4

                  great job.

                  Reageren
                2. Joss 10-09-2009 (0:15)

                  Avatar

                  *Slaps Forehead*

                  I accidentally originally downloaded the previous 1.4 version of your plugin.

                  The current version works fine :P

                  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.

                  Reageren
    93. jimmy 11-08-2009 (10:48)

      Avatar

      i cannot get the cat parameter in the archive, anything wrong?

      Reageren
      1. Rob Schlüter 11-08-2009 (11:06)

        Avatar

        What code do you use to show the list of archives?

        Reageren
        1. jimmy 12-08-2009 (4:10)

          Avatar

          i just put this code in category.php ,thanks.

          Reageren
    94. Jeremy 17-08-2009 (4:09)

      Avatar

      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!

      Reageren
    95. Geoff 17-08-2009 (22:16)

      Avatar

      Great plugin. Thanks for your work.

      Reageren
    96. Anja 3-09-2009 (17:33)

      Avatar

      It doesn’t work for me.
      It’s like there wasn’t a plugin / change. Bah, it was exactly what i was looking for

      Reageren
      1. Rob Schlüter 3-09-2009 (20:38)

        Avatar

        A few checks:
        - 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= to the URL of your blog.

        Reageren
        1. Anja 3-09-2009 (22:23)

          Avatar

          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? :P thanks

          Reageren
          1. Rob Schlüter 8-09-2009 (22:00)

            Avatar

            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.

            Reageren
    97. Joss 9-09-2009 (10:48)

      Avatar

      Hi Rob,

      This plugin looks like exactly what we’ve been looking for for a while :o )

      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!

      Reageren
      1. Rob Schlüter 9-09-2009 (12:09)

        Avatar

        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.

        Reageren
        1. Joss 9-09-2009 (13:15)

          Avatar

          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!

          Reageren
          1. Rob Schlüter 9-09-2009 (21:23)

            Avatar

            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.

            Reageren
            1. Joss 10-09-2009 (0:09)

              Avatar

              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.

              Reageren
            2. Joss 10-09-2009 (0:16)

              Avatar

              *Slaps Forehead*

              I accidentally originally downloaded the previous 1.4 version of your plugin.

              The current version works fine :P

              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.)

              Reageren
              1. Rob Schlüter 10-09-2009 (21:00)

                Avatar

                Ok, glad to know it’s not a new bug.

                Reageren
    98. Joss 9-09-2009 (13:17)

      Avatar

      Ps. I’m running the latest Wordpress, 2.8.4.

      Reageren
    99. erim 21-10-2009 (23:29)

      Avatar

      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.

      Reageren
      1. erim 22-10-2009 (2:43)

        Avatar

        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

        Reageren
        1. erim 22-10-2009 (18:48)

          Avatar

          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.

          Reageren
          1. Rob Schlüter 22-10-2009 (19:42)

            Avatar

            I’ll have to do some investigating to see if I can fix it.

            Reageren
            1. erim 26-10-2009 (20:49)

              Avatar

              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.

              Reageren
          2. Rob Schlüter 26-10-2009 (23:17)

            Avatar

            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.

            Reageren
            1. erim 27-10-2009 (18:51)

              Avatar

              Yeah, that’s about what I figured. Thanks for your help though Rob. I think I can get the host to upgrade.

              Thanks again.

              Reageren
              1. ryo 2-11-2009 (4:40)

                Avatar

                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.

                Reageren
                1. Rob Schlüter 4-11-2009 (13:09)

                  Avatar

                  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.

                  Reageren
    100. Gary 22-10-2009 (18:22)

      Avatar

      Hi, has anyone gotten this to work in Wordpress 2.8.5? Thanks!

      Reageren
      1. Rob Schlüter 26-10-2009 (23:21)

        Avatar

        Can you explain the problems, I’m not aware of any.

        Reageren
    101. victor 25-10-2009 (18:05)

      Avatar

      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

      Reageren
      1. Rob Schlüter 26-10-2009 (23:33)

        Avatar

        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.

        Reageren
    102. Erik N 27-10-2009 (0:06)

      Avatar

      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:

      Reageren
      1. Rob Schlüter 27-10-2009 (22:37)

        Avatar

        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.

        Reageren
    103. Erik N 27-10-2009 (0:07)

      Avatar

      “Select a page!

      Current: “

      Reageren
    104. awesomerobot 6-11-2009 (16:58)

      Avatar

      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.

      Reageren
      1. Rob Schlüter 6-11-2009 (22:06)

        Avatar

        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.

        Reageren
    105. Vishnu 21-12-2009 (15:07)

      Avatar

      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..

      Reageren
    106. Tom 23-12-2009 (17:40)

      Avatar

      I’m having the same problem as Vishnu. Seems be to an issue with custom permalinks. Anyone know of a fix for this?

      Reageren
      1. Tom 23-12-2009 (17:49)

        Avatar

        Actually, I fixed it by “disabling canonical URLs”. Disregard!

        Reageren
    107. Barry 11-01-2010 (22:25)

      Avatar

      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

      Reageren
      1. Rob Schlüter 12-01-2010 (9:54)

        Avatar

        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.

        Reageren
    108. Barry 11-01-2010 (22:27)

      Avatar

      Reageren
    109. Claude Schneider 24-01-2010 (19:26)

      Avatar

      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;
      }

      Reageren
    110. Dada 1-02-2010 (14:06)

      Avatar

      Thanks so much :) Works perfectly!

      Reageren

    Trackbacks

    1. WordPress 2.3 compatiblity Plugins | Dreamer's Blog
    2. WordPress Plugins Database » Plugin Details » Archives for a category
    3. 2pt3 › archive » wordpress tips
    4. AWSOM.org = Artist Website Setup Options Markup » Blog Archive » AWSOM Archive 1.4.0 released
    5. Archives for a category WordPress plugin
    6. DIY Podcasting on Wordpress | How-tos | ministrypool.com
    7. Removing Categories From A Wordpress Feed | /timelliott
    8. Plugins para Wordpress « La mala memoria
    9. Sugar Blog » Westgate Dental gets a facelift
    10. Archives for a category WordPress plugin (Kwebble blog) « wp-popular.com
    11. Include/Exclude Category from Wordpress wp_get_archives() | The Mighty Mo! Design Co. | Minneapolis Wordpress Developers and Designers
    12. wp_get_archives ????????????????? | WordPressDesign
    13. ???????????????????????? Archives for a category - ???Web?????????????????????????
    14. WordPress ????????????????????? : Serendip - Web????????????
    15. ????????????????? « ???????????????????????
    16. 3-Bein – Internetmagazin» Aktuell Blog und Internet » WP_GET_ARCHIVES modifiziert
    17. Wordpress site for Hampshire Primary School « Sugar Blog
    18. wordpress ????????????????? – blog.ao-design
    19. WordPress Plugins, die codeline.ch ermöglichen | codeline

    Reactie:

    Annuleren

  • Rubrieken

    • Artikelen
    • Foto's
    • Links
    • Media
    • Overheid
    • Programming
  • Recente Berichten

    • Tip: use the axis:axis:1.4 Maven artifact if you need Axis 1.4 support
    • Google Closure tools
    • Google en Microsoft indexeren tweets
    • De route van de Stad Amsterdam
    • Analoog of digitaal – maak je keuze
  • Gerelateerde berichten

    • Simple Cloud API
    • Showing related articles in a WordPress blog
    • Don’t forget __isset() with overloaded setters and getters
    • PHP tip: omit ?> from PHP only files
    • MySQL STRICT_TRANS_TABLES mode and truncated text values
  • Abonneren

    • Atom feed Artikelen
    • Atom feed Reacties
  • Archief

© Rob Schlüter - Contact