• Hi there,

    We are currently running a website on WP 4.3.4 (4.3.5 actually, but its not in the list). When we update to 4.4 or higher, the permalink structure we added in functions.php breaks and our website is not working as it should.

    What we have:

    • a long page with different sections
    • the homepage is a custom page, we don’t use the normal index but page-home.php and the page_on_front option in the read settings
    • each section has it’s own URL, so /about/
    • via permalinks we redirect the structure to the homepage
    • there we use PHP and JS to scroll the page to the correct section based on the URL

    This is the code we are using:

    add_filter('rewrite_rules_array', 'slug_rewrite_rules_flush');
    
    function slug_rewrite_rules_flush( $rules ) {
    
    	$home_id = get_option('page_on_front');
    
    	$urls = get_field( '_index_urls', 'options' );
    
    	foreach( $urls as $url ) :
    
    		$rules[ $url['_url_slug'].'/?$' ] = 'index.php?page_id=' . $home_id . '&redirect=' . $url['_url_slug'];
    
    	endforeach;
    
    	$_projects = get_field( '_projects', get_option('page_on_front') );
    
    	if ( !empty( $_projects ) ) :
    
    		foreach( $_projects as $_project ) :
    
    			$url_slug = get_post_field( 'post_name', $_project->ID );
    
    			$rules[ get_post_type( $_project->ID ) .'/'. $url_slug .'/?$' ] = 'index.php?page_id=' . $home_id . '&redirect=' . get_post_type( $_project->ID ) . '&work_id=' . $_project->ID;
    
    		endforeach;
    
    	endif;
    
    	return $rules;
    
    }

    The ‘get_field’ function is from advanced custom fields plugin. _index_urls is an array with URL names, so about, contact, etc…

    The problem is that before the update, we ended up on the homepage with the current URL, say for example: http://www.url.nl/about/

    After the update we still end up in the homepage, but the page is being redirected, loosing the path in the URL. So we end up in http://www.url.nl/

    Has anybody any clue what changed in 4.4 that this is not working any more?

    Live example BEFORE the update:
    http://www.raakvideo.nl

    Thanks in advance for any advice!

  • The topic ‘Permalink Redirects not working any more after WP 4.4 update’ is closed to new replies.