Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chriskyfung/6b7e5d21a19b872b0aeec103e43de4e5 to your computer and use it in GitHub Desktop.
Save chriskyfung/6b7e5d21a19b872b0aeec103e43de4e5 to your computer and use it in GitHub Desktop.
Custom PHP Snippets for WordPress with WP2Static Plugin
<?php
// Function to add additional URLs to the URL queue
function add_additional_urls( $url_queue ) {
// Array of additional URLs to add
$additional_urls = array(
'/ads.txt',
'/_redirects',
// Add your URL paths below:
// '/en/category/category1/page/2/',
// '/en/category/category1/page/3/',
// '/en/category/category1/page/4/'
);
// Merge additional URLs with the existing URL queue
$url_queue = array_merge(
$url_queue,
$additional_urls
);
return $url_queue;
}
// Hook the function to modify the initial crawl list
add_filter( 'wp2static_modify_initial_crawl_list', 'add_additional_urls' );
?>
@chriskyfung
Copy link
Author

This code snippet is useful for developers who need to dynamically add additional URLs to a URL queue in WordPress. The add_additional_urls function allows for easily specifying and merging new URLs to the existing queue. By using this code, developers can customize and expand the initial crawl list by hooking into the wp2static_modify_initial_crawl_list filter. This can be handy for various purposes like including specific pages, paths, or resources that should be crawled and processed in a web application or website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment