custom post types – 404 error rewrite permalinks

Question

I have a issue with my rewrite url and I hope somebody can help me out.

add_action('init', 'my_custom_rewrite'); 
function my_custom_rewrite() {

    add_permastruct('catalog', '/%customname%/', true);
    global $wp_rewrite;
    $wp_rewrite->add_rewrite_tag("%customname%", '([^/]+)', "catalog=");
}

add_filter( 'post_type_link', 'my_custom_permalinks', 10, 2 );
function my_custom_permalinks( $permalink, $post ) {
      return str_replace( '%customname%/', $post->post_name."https://wordpress.stackexchange.com/".$post->ID, $permalink );
}

After this I go to settings->permalinks and push save to flush but I get an 404 error and my url has 2 times the ID like domain.com/post-name/postID/postID

Who can help me out with this?

0
Liekeee 1 year 2021-11-09T12:17:21-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse