custom post types – 404 error rewrite permalinks


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."".$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

Who can help me out with this?

Liekeee 2 years 2021-11-09T12:17:21-05:00 0 Answers 0 views 0

Leave an answer