I have a
Now I want to dynamically have pages on my site with the following URL Structure
example.com/awards/oscars/year/2011
example.com/awards/oscars/best-actor/ (which will list all the winners of best actor award till now of all years)
I need to get these url structures working in WordPress. Any Advice?
Thanks in Advance :)
Example for: example.com/awards/oscars/year/2011
This might help you. Put below code into your functions.php file:
function custom_rewrite_basic() {
add_rewrite_rule('^awards/([A-Za-z0-9._-]+)/year/([0-9]+)/?', 'your_actual_working_file_url.php?award_type_slug=$matches[0]&year=$matches[3]', 'top');
}
add_action('init', 'custom_rewrite_basic');
RewriteRule ^awards/([A-Za-z0-9._-]+)/year/([0-9]+)/?$ your_actual_working_file_url.php?award_type_slug=$1&year=$2
Make sure you put your actual working file url/path in above code as per your custom template file name or default template file name.