My website is http://www.saealumni.com.au/ .
At the moment you can view the "news" category via the URL: http://www.saealumni.com.au/?category=news
I'm attempting to make it work so that you can use the URL: http://www.saealumni.com.au/category/news/
I also need to be able to echo the value of the variable on the page itself, via something like:
echo get_query_var('category');
In my functions.php file, I have the following code:
function directory_flush_rewrite()
{
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
add_action('init', 'directory_flush_rewrite');
function directory_vars($public_query_vars)
{
$public_query_vars[] = 'category';
return $public_query_vars;
}
add_filter('query_vars', 'directory_vars');
function my_rewrite_rules( $rewrite_rules ) {
$new_rules = array( 'category/([^/]+)' => 'index.php?category=$matches[1]' );
$rewrite_rules = $new_rules + $rewrite_rules;
return $rewrite_rules;
}
add_filter('rewrite_rules_array', 'my_rewrite_rules');
But it's doing nothing. echo get_query_var('category'); does not work, and the permalinks 'aint pretty.
Have I missed something important? I've been sitting here all morning trying a million different variations on the same sort of code, but nothing seems to have any effect.
Any ideas?
Thanks in advance,
Hadyn