Last active
May 4, 2024 03:37
-
-
Save chriskyfung/6b7e5d21a19b872b0aeec103e43de4e5 to your computer and use it in GitHub Desktop.
Custom PHP Snippets for WordPress with WP2Static Plugin
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 | |
// 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' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 thewp2static_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.