Posted By

pdswan on 07/24/09


Tagged

php wordpress category archive


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

joelhaus
rspindel


Date Based Category Archives for Wordpress


 / Published in: PHP
 

  1. function extend_date_archives_flush_rewrite_rules(){
  2. global $wp_rewrite;
  3. $wp_rewrite->flush_rules();
  4. }
  5. add_action('init', 'extend_date_archives_flush_rewrite_rules');
  6.  
  7. function extend_date_archives_add_rewrite_rules($wp_rewrite){
  8. $rules = array();
  9. $structures = array(
  10. $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
  11. $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
  12. $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
  13. );
  14. foreach( $structures as $s ){
  15. $rules += $wp_rewrite->generate_rewrite_rules($s);
  16. }
  17. $wp_rewrite->rules = $rules + $wp_rewrite->rules;
  18. }
  19. add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');

Report this snippet  

You need to login to post a comment.