toggle menu

Custome Post type link update after getting 301 redirection error for the pages

Dhananjay Kumar |23 May at 01:05

We have created custom post type by function.php and changing URL by category alais before the name by below code

function custom_post_link( $post_link, $id = 0 ){
    $post = get_post($id); 
    if ( is_object( $post )){
        $terms = wp_get_object_terms( $post->ID, 'custom_category' );
        if( $terms ){
            return str_replace( '%custom_category%' , $terms[0]->slug , $post_link );
        }
    }
    return $post_link; 
}
add_filter( 'post_type_link', 'custom_post_link', 1, 3 );

 

after using this script pages redirection error with multiple "301 redirection on page issues".

Suggest, if any have solution about this.

  • 0 like
  • 0 comment

Posted:

23 May at 01:05

Viewed:

1141 times

Active:

23 May at 01:05