• Hi, need to set individual priority values for pages, posts, categories, tags, can you show an example how can i implement this?
    this work fine but this work for all post type… Thanks for help

    add_filter( 'wp_sitemaps_posts_entry', 'add_sitemap_tags', 25, 2 );
     
    function add_sitemap_tags( $entry, $post ) {
     
    	$entry[ 'priority' ] = '40%';
    	$entry[ 'changefreq' ] = 'Monthly';
    	$entry[ 'lastmod' ] = $post->post_modified_gmt;
     
    	return $entry;
     
    }
Viewing 1 replies (of 1 total)
  • Thread Starter md_hedji

    (@md_hedji)

    Now i have other problem i solve problem above, i cant find in filter wp_sitemaps_posts_entry how i can change priority for homepage (i use static home page set in wp-admin/options-reading.php static page)

    add_filter( 'wp_sitemaps_posts_entry', 'add_sitemap_tags_post', 10, 2 );
     
    function add_sitemap_tags_post( $sitemap_entry, $post, $post_type ) {
     
            if ( 'post' == $post->post_type ) {
                $sitemap_entry[ 'priority' ] = '0.5';
            }
            if ( 'page' == $post->post_type  ) {
        	    $sitemap_entry[ 'priority' ] = '0.6';
            } 
        $sitemap_entry[ 'changefreq' ] = 'weekly';
        $sitemap_entry[ 'lastmod' ] = $post->post_modified_gmt;
     
        return $sitemap_entry;
     
    }
    
    add_filter( 'wp_sitemaps_taxonomies_entry', 'add_sitemap_tags_tax', 10, 3 );
     
    function add_sitemap_tags_tax( $sitemap_entry, $term, $taxonomy ) {
     
             if ( $taxonomy == 'category' )  {
        	    $sitemap_entry[ 'priority' ] = '0.8';
            }
    
    	if  ( $taxonomy == 'post_tag' )  {
        	    $sitemap_entry[ 'priority' ] = '0.6';
            }
    
        $sitemap_entry[ 'changefreq' ] = 'weekly';
     
        return $sitemap_entry;
     
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Sitemap Priority depend on post_type’ is closed to new replies.