Exclude single url (archive) from sitemap

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math today.

    To remove the archive page from sitemap, just head to the page and set it to noindex. You can also use this filter: https://rankmath.com/kb/filters-hooks-api-developer/#exclude-taxonomy-from-sitemap

    You can use this filter to change the XML url: https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-post-url

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Michael,
    Thanks for the reply. I have seen the filters but I can’t wrap my head around how to use them. Are there any specific examples?

    I tried this, but the url still show up in the sitemap:

    /**
     * Filter the URL Rank Math SEO uses in the XML sitemap for this post type archive.
     *
     * @param string $archive_url The URL of this archive
     * @param string $post_type   The post type this archive is for.
     */
    $archive_url = 'https://www.lokaalvastgoed.be/listings/';
    $post_type = 'job_listing';
    add_filter( 'rank_math/sitemap/post_type_archive_link', function( $archive_url, $post_type ){
    	return $archive_url;
    }, 10, 2 );

    Hello,

    I have created the following example to exclude taxonomy.

    /**
     * Filter decision if taxonomy is excluded from the XML sitemap.
     *
     * @param bool   $exclude Default false.
     * @param string $type    Taxonomy name.
     */
    add_filter( 'rank_math/sitemap/exclude_taxonomy', function( $exclude, $type ){
            if ( 'listings' === $type ) {
    		return true;
    	}
    	return $exclude;
    }, 10, 2 );
    

    Hoping that helps you. Thank you.

    ​​​​​​

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this ticket.