Skip to content

Instantly share code, notes, and snippets.

@alfonso100
alfonso100 / wpr-sitemap-generator.php
Created January 24, 2025 14:06
wpr-sitemap-generator.php
// Create a custom sitemap with the lastest n posts, and updates it after saving a post.
// Useful for big sites.
// Writes an xml file in the root level of the wp install: https://example/my-custom-sitemap.xml
add_action( "save_post", "wpr_create_custom_sitemap" );
function wpr_create_custom_sitemap() {
if ( str_replace( '-', '', get_option( 'gmt_offset' ) ) < 0 ) {
$tempo = '-0' . str_replace( '-', '', get_option( 'gmt_offset' ) );
} else {
$tempo = get_option( 'gmt_offset' );
<?php
/**
* Plugin Name: WP Rocket | Remove Post URLs from purge based on strings
* Description: Removes URLs from WP Rocket’s automatic cache purging based on a partial string match.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
*/