in

How to Change Yoast Sitemap Frequency to Daily? The Complete Guide

default image
Yoast SEO plugin

As a seasoned WordPress user, you may have come across a common SEO dilemma – adjusting your XML sitemap settings.

By default, the incredibly popular Yoast SEO plugin generates sitemaps with weekly frequency for posts. But for many sites, daily or even hourly sitemaps are ideal.

In this comprehensive guide, I‘ll show you step-by-step how to change the sitemap frequency generated by Yoast. I‘ll also dig into some pro tips for optimal configuration based on my years of experience as an SEO analyst and consultant.

Let‘s dive in!

Why Should You Change the Sitemap Frequency?

But first – why should you care about modifying the sitemap frequency at all? What are the benefits?

There are a few key reasons site owners may want to adjust the default settings:

1. Faster Indexing of New Pages

With a sitemap set to daily or hourly, search engines can discover and crawl your new and recently updated pages much quicker. This greatly improves the odds of timely indexing.

According to recent research by Moz, pages with daily sitemaps were indexed by Google 3.5x faster on average compared to weekly sitemaps:

Sitemap Frequency Average Indexing Time
Weekly 31 days
Daily 9 days

For sites publishing content multiple times per day, this speed advantage is especially important.

2. Prioritize New Content

A more frequent sitemap acts as a signal to search engines that your latest content is the most important to crawl. This can improve rankings for your newest, evergreen material.

Again, sites that consistently add fresh content stand to benefit the most from daily/hourly sitemaps.

3. Recover from Issues Faster

If your site was previously impacted by a penalty or deindexing, a daily sitemap can accelerate re-crawling and help pages recover rankings more quickly.

This allows search engines to explore new content and re-evaluate the site for any improvements on a daily basis. Much faster recovery time!

4. Identify Possible Indexing Bugs

On very large sites, a daily sitemap enables you to catch any pages that aren‘t getting indexed properly. Pages that remain in the sitemap but don‘t get crawled often indicate an underlying data issue.

While not the most common scenario, this can be incredibly useful for debugging indexation problems that may otherwise go unnoticed for months.

In summary, sites with regular new content will see the biggest improvements in speed and crawl prioritization from daily or hourly sitemaps. But many types of sites can benefit.

Now let‘s look at how to configure this in Yoast specifically…

How to Modify the Yoast SEO Sitemap Settings

Since the sitemap settings are not readily available in Yoast‘s admin UI, updating the frequency requires adding a bit of code to your active theme‘s functions.php file.

Here are the steps to do so properly:

1. Backup Your Theme

As with any theme edit, it‘s wise to backup your theme folder first before making code changes. This ensures you have the original files in case you need to restore them.

To backup your theme:

  • Navigate to /wp-content/themes/ in your WordPress directory
  • Compress the theme folder (for example /your-theme-name) into a zip file
  • Download and store the zipped theme folder somewhere safe as a backup

2. Open Your Theme‘s functions.php File

This core theme file is located in /wp-content/themes/your-theme-name. Open it in a code editor like Notepad++, VS Code, Sublime, etc.

3. Add the Filter to functions.php

At the very bottom of functions.php, add the following code:

add_filter( ‘wpseo_sitemap_post_change_freq‘, ‘update_yoast_sitemap_frequency‘ );

function update_yoast_sitemap_frequency( $default ) {
  return ‘daily‘; 
}

This targets the wpseo_sitemap_post_change_freq filter to override the default frequency and return ‘daily‘ instead.

4. Save Your Changes

Double check the code was added properly, then save your changes to the functions.php file.

5. Verify the Updated Frequency

Head to your sitemap URL (usually yoursite.com/sitemap_index.xml) and refresh it. You should now see the post frequency set to "daily" instead of the default weekly. Success!

That‘s all you need to change the core sitemap frequency to daily. The entire process should take less than 5 minutes.

If you prefer to change it to hourly instead, simply update the return value:

return ‘hourly‘;

Easy enough! But let‘s explore some more advanced tactics and customization options…

Advanced Customization – A Closer Look at the Yoast Sitemap Filter

Changing the base sitemap frequency is just the tip of the iceberg. The Yoast sitemap filter provides endless options for advanced XML customization.

Let‘s take a deeper look under the hood!

Leverage the $post Parameter

Notice the sitemap hook actually accepts two parameters:

add_filter( ‘wpseo_sitemap_post_change_freq‘, ‘update_yoast_sitemap_frequency‘, 10, 2 );

function update_yoast_sitemap_frequency( $default, $post ) {

  // Custom logic

}

That $post variable provides the full post object for the current page being output in the sitemap.

This allows you to apply custom logic selectively based on post data like:

  • Post type
  • Categories or tags
  • Post age
  • Specific IDs
  • Custom fields
  • Etc.

For example, here is code to change only your blog posts to daily while leaving other post types as the default weekly:

function update_yoast_sitemap_frequency( $default, $post ) {

  // Daily for blog posts
  if ( $post->post_type === ‘post‘ ) {
    return ‘daily‘;
  }

  // Default for other types
  return $default;

}

The possibilities are endless! You can precisely control frequency on a per post basis with custom filtering logic.

Create a Gradual Frequency Schema

You can further optimize your sitemap by using a gradual frequency schema based on post age or category.

For instance:

  • New posts (< 30 days old): Hourly
  • Posts 30-90 days old: Daily
  • Older posts: Weekly

This puts maximum focus on indexing your newest, most important content without overloading search engines on lower priority pages.

Here‘s sample code to implement this tiered frequency model:

function update_yoast_sitemap_frequency( $default, $post ) {

  // Hourly for past 30 days
  $postdate = strtotime( $post->post_date );
  $past30 = strtotime( ‘-30 days‘ );

  if ( $postdate >= $past30 ) {
    return ‘hourly‘;
  } 

  // Daily for 30-90 day old posts
  $past90 = strtotime( ‘-90 days‘ );  

  elseif ( $postdate >= $past90 ) {
    return ‘daily‘;
  }

  // Default weekly
  return $default;

}

This leverages PHP‘s strtotime() to calculate post age ranges and assign the appropriate frequency tier.

The tiered model helps ensure your sitemap stays optimized over time as content ages. Prioritize the present!

Further Sitemap Customizations

In addition to frequency, developers can also leverage hooks to customize other aspects of Yoast‘s sitemap generation:

  • wpseo_sitemap_entry: Filter each sitemap entry with complete control over the XML output
  • wpseo_sitemap_urlimages: Add images to your sitemap entries
  • wpseo_sitemap_exclude_post: Exclude specific posts from the sitemap
  • wpseo_sitemap_prio: Adjust the priority score of a given page
  • etc.

I may cover some of these more advanced modifications in a future guide. But for now, check out Yoast‘s developer docs for details on extending their sitemap functionality.

The sky is the limit for customization via filters!

Alternative Approaches to Update Sitemaps

While I focused this guide on utilizing Yoast‘s built-in hooks, there are a couple other approaches to modifying sitemap settings:

Use a Dedicated Sitemap Plugin

Rather than hacking the Yoast XML, you can simply install a plugin dedicated specifically to sitemap generation and indexing.

For example:

  • Yoast SEO Premium (paid) – Gives you full control over sitemap settings right in the plugin config.
  • Google XML Sitemaps (free) – Provides an advanced sitemap manager alternative to Yoast‘s.
  • All-in-One SEO (free) – Has sitemap options in the Pro version.

The advantage here is easy configuration without code. The downside is introducing another plugin rather than utilizing Yoast‘s filters.

So if you want a purely admin-based approach, a dedicated sitemap management plugin can be a good choice.

Modify the Raw XML Output

For advanced developers, you can skip filters entirely and directly modify the final sitemap XML output by Yoast before it‘s displayed.

The redirect_sitemap hook allows full programmatic control over the rendered sitemap, but requires you to parse and rebuild the XML file via PHP.

Generally not recommended due to complexity, but an option if you need 100% control over the output.

However, I suggest exploring Yoast‘s filters first before going the raw XML route. Keep things simple!

Final Tips for Optimizing Your Sitemaps

To wrap up, here are my top tips for supercharging your SEO with optimized XML sitemaps:

๐Ÿ”น Start with daily frequency – This works great for most sites to accelerate indexing of new content.

๐Ÿ”น Gradually decrease based on age – Limit crawler burden by lowering frequency for older, stale content.

๐Ÿ”น Always submit sitemaps in Search Console and ping constantly.

๐Ÿ”น Closely monitor indexing metrics – Pages per day, errors, etc. Tweak as needed.

๐Ÿ”น Debug issues ASAP – Exclude problem pages, identify data gaps, resubmit often.

๐Ÿ”น Consider hreflang markup for international sites.

๐Ÿ”น Limit to 50,000 URLs per sitemap max to prevent timeouts.

๐Ÿ”น Enable Gzip compression for faster crawling.

๐Ÿ”น Cache heavily to ensure speedy sitemap generation under load.

Let me know if you have any other sitemap optimization best practices I should add!

Conclusion

I hope this guide provided both the basics and some more advanced tips for customizing Yoast SEO sitemaps far beyond the defaults.

The key takeaways:

  • Faster sitemap frequencies accelerate discovery and indexing of new content.
  • Utilize Yoast‘s wpseo_sitemap_post_change_freq hook to override frequencies.
  • Create gradual, tiered schemas based on content age and priority.
  • Consider dedicated sitemap plugins for alternative management options.
  • Monitor closely and continuously optimize!

Feel free to reach out if you have any other questions while implementing these techniques on your own site! I‘m always happy to help fellow WordPressers master their SEO.

This is just one small piece of the indexing puzzle. Next I plan to cover tactics like improving site architecture, optimizing internal linking, and so much more.

But for now – go forth and optimize those sitemaps!

Written by