so I was asked to create url rewrites for one of the websites we're working on, but the thing is the test rewrite I did, just to try it out, is not really working.
here's the code I put in the functions.php file of the theme, to do url rewrites;
add_action( 'init', 'initialize_my_theme' );
function initialize_my_theme() {
register_nav_menu('primary','MainMenu');
add_filter( 'query_vars', 'campedia_set_query_vars' );
}
function campedia_set_query_vars( $vars ) {
//array_push( $vars, 'learner_id' );
return $vars;
}
function campedia_activate() {
// register taxonomies/post types here
flush_rewrite_rules();
add_rewrite_rule('^nutrition/.+','view-profile/#','top');
}
register_activation_hook( __FILE__, 'campedia_activate' );
function campedia_deactivate() {
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'campedia_deactivate' );
now I know you can't just take the examples from the wordpress site and expect everything to work - [cos their examples almost never work for the complicated stuff] - but I got practically all of this code from their website and it's not working, this is the third thing I tried and each time I'm just redirected to the home page. why?!