• I know this is a long shot, but I have a custom post type ‘latest_resources’ which is being registered via a theme function. I am rewriting the permalink structure this way:

    $args = [
    ....
    "rewrite" => [ "slug" => "resources/%resource_type%", "with_front" => false ],
    ....
    ];
    register_post_type( "latest_resource", $args );

    Then, I use a filter to replace the string %resource_type% with the custom taxonomy term:

    function resources_change_permalinks( $post_link, $post ){
    if ( is_object( $post ) && $post->post_type == 'latest_resource' ){
    $terms = wp_get_object_terms( $post->ID, 'resource_type' );
    if( $terms ){
    return str_replace( '%resource_type%' , $terms[0]->slug , $post_link );
    }
    }
    return $post_link;
    }
    add_filter( 'post_type_link', 'resources_change_permalinks', 1, 2 );

    Works great. And in the Yoast Sitemap under latest_resource-sitemap.xml all of the permalinks appear exactly how I want them. Everything looks wonderful…

    EXCEPT the very first entry in the latest_resource-sitemap.xml sitemap is:

    https://www.myURL.com/resources/%resource_type%/

    I am unsure how to troubleshoot. Is there a way I can filter the sitemap to ensure this string is not included? Should I be rewriting the permalink structure another way?

    Any insight or advice is greatly appreciated. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hi @rcneil

    You can try to use filters to remove the specific item from sitemap.

    We recommend creating regular backups of your site and database for your site’s health and safety. A backup is crucial before making important changes on your website and provides you with a safety net if something were to go wrong. Learn more about the benefits of regular backups.

    Your question is a bit outside the scope of our support. The support team is here to help you with questions about the setup and basic use of the plugin. As much as we’d love to help, is beyond what we can do for our users.

    I have the same case, when I have custom post type with rewriting the permalink structure. And besides the problem described above I noticed that when you go to Yoast SEO -> Settings, after clicking on the Custom Post Type tab, a page opens with the URL “/wp-admin/admin.php?page=wpseo_page_settings#/site-features” instead of “/wp-admin/admin.php?page=wpseo_page_settings#/post-type/post_type_slug”.

    How to fix this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.