I'm creating a site where users work together on teams to create films. Currently, I'm setting up an edit page on the front end for team managers. I've just got a simple isset() check on a query var without a value to send the view to the new template page. So, regardless of the query var's value, if it's called in the URL it goes to the new template.
That part is working. The template is loading just fine at /team/(teamname)?manage. And all I'm trying to do is rewrite it so that it looks like /team/(teamname)/manage instead.
But my problem is that it's not working, AND every page on the front end is now redirecting to index.php. All except for index.php?team=blah&manage and other custom posts being called with ?team= .
Here's my file for custom rewrite rules:
function generate_manage_rewrite_rules() {
global $wp_rewrite;
$new_rules = array(
"(team|film)/([^/]+)/manage/?$" => "index.php?".$wp_rewrite->preg_index(1)."=".$wp_rewrite->preg_index(2)."&manage"
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_filter('rewrite_rules_array', 'generate_manage_rewrite_rules');
My .htaccess file which I haven't touched:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sitename/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sitename/index.php [L]
</IfModule>
# END WordPress
And my file for setting template redirect and query vars (even though I don't think this is the problem):
function templateInclude( $template )
{
if (is_single()) {
global $wp_query;
if( isset ( $wp_query->query_vars['manage'] ) ) {
if ( is_manager() ) {
$new_template = locate_template( array( '/template-team-manage.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
}
}
return $template;
}
add_action( 'template_include', 'templateInclude' );
I've also tried installing the Rewrite Analyzer plugin to try to figure things out, but it's not loading at all for me after installing.