Skip to content

Instantly share code, notes, and snippets.

@JacobLett
Last active November 19, 2019 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacobLett/553e9ffc43b4364e99b682945ea331f8 to your computer and use it in GitHub Desktop.
Save JacobLett/553e9ffc43b4364e99b682945ea331f8 to your computer and use it in GitHub Desktop.
wordpress get a list of all urls that you can save as CSV - https://www.computerhope.com/issues/ch001356.htm
<?php
include "wp-load.php";
/**/
// Get All Post Types as List
foreach ( get_post_types( '', 'names' ) as $post_type ) {
echo "{$post_type}\n";
//echo $post_type ."<br>";
}
// Step 1. Paste all of the post types into this array below
// Step 2. Save page as .csv and remove the post types at the top
$posts = new WP_Query(array(
'post_type' => array(
'post',
'page',
'attachment',
'revision',
'nav_menu_item',
'custom_css',
'customize_changeset',
'oembed_cache',
'user_request',
'wp_block',
'acf-field-group',
'acf-field',
'wpcf7_contact_form',
'custom-css-js',
'case_study',
'industry',
'use_case',
'video',
'training_cpt',
'webinar',
'literature_cpt',
'leadership_cpt',
'product',
'press_release',
'news_cpt',
'event',
'gated',
'thank_you',
'role',
'partner',
'testimonial',
'tutorial'
),
'posts_per_page' => -1,
'post_status' => 'publish',
'depth' => -1
));
//$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish&depth=-1');
$posts = $posts->posts;
header('Content-type:text/plain');
echo "URL,";
echo "Type,";
echo "Date,";
echo "Title\n";
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;
}
$title = get_the_title($post->ID);
$postType = get_post_type($post->ID);
$postDate = get_the_date('Y-m-d');
echo "{$permalink},";
echo "{$postType},";
echo "{$postDate},";
echo "{$title}\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment