Comment pagination not work wIth Custom permalinmk structure
-
Hello,
I Rewrite the permalink rule for custom permalink structure, As below
/* add city wise permalink*/
add_action(‘init’, ‘add_custom_rewrite_rules’);function add_custom_rewrite_rules() { global $wp_rewrite; $wp_rewrite->add_rewrite_tag('%city%', '([^/]+)', 'city='); $pid = get_option('default_comments_page'); if($pid =='last'){ $pid ='1'; }else{ $pid ='1';} $location_post_type=get_option('location_post_type'); if($location_post_type!='' ||!empty($location_post_type)){ foreach($location_post_type as $post_type){ $posttype=explode(',',$post_type); $wp_rewrite->add_rewrite_tag('%'.$posttype[0].'%', '([^/]+)', $posttype[0].'='); //$wp_rewrite->add_rewrite_tag('%event%', '([^/]+)', 'event='); $wp_rewrite->add_permastruct($posttype[0], '/city/%city%/'.$posttype[0].'/%'.$posttype[0].'%', false); //$wp_rewrite->add_permastruct('event', '/city/%city%/event/%event%', false); } $wp_rewrite->flush_rules(); if(function_exists('flush_rewrite_rules')){ // $ver = filemtime( __FILE__ ); // Get the file time for this file as the version number $defaults = array( 'version' => 0, 'time' => time() ); $r = wp_parse_args( get_option( __CLASS__ . '_flush', array() ), $defaults ); if ( $r['version'] != $ver || $r['time'] + 86400 < time() ) { // Flush if ver changes or if 48hrs has passed. flush_rewrite_rules(true); // trace( 'flushed' ); $args = array( 'version' => $ver, 'time' => time() ); if ( ! update_option( __CLASS__ . '_flush', $args ) ) add_option( __CLASS__ . '_flush', $args ); } // } } }
then use the “post_type_link” filter which return the permalink
add_filter('post_type_link', 'create_custom_permalinks', 10, 3);
Custom permalink for detail page is work fine ,But It creates the problem when i use “ Comments pagination ” , When i click on pagination button it redirect me to the 404 page.
Link e.g. https://localhost/mythemes/city/new-york/listing/zavino-pizzeria-and-wine-bar/comment-page-1/#comments = 404If i comment the permalink code then work fine .
if i remove “comment-page-1” theme page comes fine..
Can anyone help me to resolve this……
- The topic ‘Comment pagination not work wIth Custom permalinmk structure’ is closed to new replies.