From bab2c176b07073df0a41a9f75d65812c948a1f0b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 30 Aug 2016 11:36:32 -0400 Subject: [PATCH] Testing fix for 404s on detail pages --- setup/frontHooks.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index b52eed71..28d181f2 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -26,6 +26,24 @@ * Also note that parameters will be in the context of the main front controller constructor. */ +// Setup rewrite for member detail pages +add_filter('rewrite_rules_array', function($rules) { + + // Check if rule is not set + if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$'] ) ) { + + // Add the new rule + $newrules = array(); + $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&memberslug=$matches[2]'; + return $newrules + $rules; + } + + // If already set, just return the rules unchanged. + return $rules; + +}); + +/* This code is being replace for testing by the above to avoid intermittent 404's on the detail pages. // Check if the canonical member page rewrite rule is not currently in place. $rules = get_option( 'rewrite_rules' ); if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$'] ) ) { @@ -44,6 +62,7 @@ if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/( }); } +*/ /* * Add a filter to correct rel_canonical header entries -- 2.17.1