<?php
function list_all_archive_urls() {
$urls = [];
// Category archives
$categories = get_categories([
'hide_empty' => true,
]);
foreach ($categories as $category) {
$urls[] = get_category_link($category->term_id);
}
// Tag archives
$tags = get_tags([
'hide_empty' => true,
]);
foreach ($tags as $tag) {
$urls[] = get_tag_link($tag->term_id);
}
// Author archives
$authors = get_users([
'who' => 'authors',
'has_published_posts' => true,
]);
foreach ($authors as $author) {
$urls[] = get_author_posts_url($author->ID);
}
// Custom post type archives
$post_types = get_post_types([
'public' => true,
'_builtin' => false, // Exclude built-in post types like post/page
'has_archive' => true,
], 'objects');
foreach ($post_types as $post_type) {
if (!empty($post_type->has_archive)) {
$urls[] = get_post_type_archive_link($post_type->name);
}
}
return $urls;
}
// Example output:
$archive_urls = list_all_archive_urls();
foreach ($archive_urls as $url) {
echo esc_url($url) . "<br>";
}
?>
[
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
]
214