Skip to content

Instantly share code, notes, and snippets.

@pixeline
Last active January 23, 2018 12:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pixeline/a85cf4d6208941794800d37c77a7a5b7 to your computer and use it in GitHub Desktop.
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.
<?php
/*
*
* WP-siege: Generates list of all published URLs from a Wordpress site, for use with Siege.
* Author: Alexandre Plennevaux alexandre@pixeline.be
*
*/
//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