Last active
January 23, 2018 12:45
-
-
Save pixeline/a85cf4d6208941794800d37c77a7a5b7 to your computer and use it in GitHub Desktop.
WP-siege: Generates list of all published URLs from a Wordpress site, for use with Siege.
This file contains hidden or 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 | |
/* | |
* | |
* WP-siege: Generates list of all published URLs from a Wordpress site, for use with Siege. | |
* Author: Alexandre Plennevaux [email protected] | |
* | |
*/ | |
//path to a wp-load file | |
include( './wp-load.php' ); | |
$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish'); | |
$posts = $posts->posts; | |
header('Content-type:text/plain'); | |
echo get_bloginfo('url'); | |
foreach($posts as $post) { | |
switch ($post->post_type) { | |
case 'revision': | |
case 'nav_menu_item': | |
break; | |
case 'page': | |
$permalink = get_page_link($post->ID); | |
break; | |
case 'post': | |
$permalink = get_permalink($post->ID); | |
break; | |
case 'attachment': | |
$permalink = get_attachment_link($post->ID); | |
break; | |
default: | |
$permalink = get_post_permalink($post->ID); | |
break; | |
} | |
echo "\n".trim($permalink ); | |
} | |
// All archives | |
$args = array( | |
'public' => true | |
); | |
$taxs = get_taxonomies($args, 'objects'); | |
foreach ($taxs as $tax){ | |
$terms = get_terms( | |
$tax->name, | |
array( | |
'hide_empty' => true, | |
) | |
); | |
foreach ($terms as $term) { | |
$permalink = get_term_link ($term); | |
echo "\n".trim($permalink ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment