Wordpress rewrite url with query parameters -
i have post categories based 1 year, month , date
categories
2013 may 14 april 10 2012 june 6
i creating rewrite urls particular date categories
creating url category/slug-name/issues/year/month/date
my rewrite url below
add_action('generate_rewrite_rules', 'past_issue_rewrite_rules'); function past_issue_rewrite_rules( $wp_rewrite ) { $wp_rewrite->rules = array_merge( array('category/past-issues/issues/(.+)/(.+)/ (.+)/' => 'category/past-issues/?year='.$wp_rewrite->preg_index(1).'&month='. $wp_rewrite->preg_index(2).'&day='.$wp_rewrite->preg_index(3)), $wp_rewrite->rules ); } add_filter( 'query_vars', 'setup_filter_query_vars' ); function setup_filter_query_vars( $query_vars ) { $query_vars[] = 'year'; $query_vars[] = 'month'; $query_vars[] = 'day'; return $query_vars; }
when tried access page showing page not found. error? possible send parameters category.php
page
i not sure. please let me know if wrong.
i found s0lution myself , here code
function past_issue_rewrite_rules(){ add_rewrite_rule( 'category/past-issues/(\d+)/(\d+)/(\d+)/?$', 'index.php?category_name=past-issues&pyear=$matches[1]&pmonth=$matches[2]&pday=$matches[3]', 'top' ); } add_action( 'init', 'past_issue_rewrite_rules' ); add_filter( 'query_vars', 'setup_filter_query_vars' ); function setup_filter_query_vars( $query_vars ) { $query_vars[] = 'pyear'; $query_vars[] = 'pmonth'; $query_vars[] = 'pday'; return $query_vars; }
Comments
Post a Comment