Advertisement
jaideep06

Include sitemap

Nov 6th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. include_once 'custom-sitemap.php';
  3. add_filter('rank_math/sitemap/providers', function( $external_providers ) {
  4.     $external_providers['custom'] = new \RankMath\Sitemap\Providers\Custom();
  5.     return $external_providers;
  6. });
  7.  
  8. add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {
  9.     if ( 'post' == $type ) {
  10.         if ( $object->ID == 457 ) {
  11.             return false; // Remove this entry from the sitemap
  12.         }
  13.  
  14.         if ( $object->post_parent == 457 ) {
  15.             return false; // Remove this entry from the sitemap
  16.         }
  17.     }
  18.  
  19.     return $url; // Return the URL if it doesn't match the exclusion criteria
  20. }, 10, 3 );
  21.  
  22. add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement