Last active
November 2, 2021 13:17
-
-
Save amboutwe/5392b77d67c9a4bc417fa62899422e4c to your computer and use it in GitHub Desktop.
Add the Yoast SEO sitemap index to the WordPress generated robots.txt file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Add Sitemap Index To Generated Robots.txt | |
* Credit: Ben https://github.com/retlehs | |
* Last Tested: Mar 13 2017 using Yoast SEO 4.4 on WordPress 4.7.3 | |
*/ | |
add_action('do_robots', 'custom_robotstxt'); | |
function custom_robotstxt() { | |
echo 'Sitemap: ' . get_home_url() . '/sitemap_index.xml'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment