404 error solution
-
Hi!
To fix 404 error I’ve made a fix in the custom_permalinks_original_post_link method. File custom-permalinks/frontend/class-custom-permalinks-frontend.php.It works.
public function custom_permalinks_original_post_link( $post_id ) { remove_filter( 'post_link', array( $this, 'custom_permalinks_post_link' ), 10, 3 ); remove_filter( 'post_type_link', array( $this, 'custom_permalinks_post_link' ), 10, 2 ); require_once ABSPATH . '/wp-admin/includes/post.php'; list( $permalink, $post_name ) = get_sample_permalink( $post_id ); // START FIX ERROR 404 global $wpdb; $existing_post_name = $wpdb->get_var( "SELECT post_name FROM {$wpdb->posts} WHERE ID = " . ((int)$post_id ) ); if( $existing_post_name ) $post_name = $existing_post_name; // END FIX $permalink = str_replace( array( '%pagename%','%postname%' ), $post_name, $permalink ); $permalink = ltrim( str_replace( home_url(), '', $permalink ), '/' ); add_filter( 'post_link', array( $this, 'custom_permalinks_post_link' ), 10, 3 ); add_filter( 'post_type_link', array( $this, 'custom_permalinks_post_link' ), 10, 2 ); return $permalink; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘404 error solution’ is closed to new replies.