寻找一种方法来导出WordPress中带有相应帖子标题的漂亮永久链接列表.寻找实际的永久链接结构而不是短链接.我想如果需要的话,我会使用短链接,但我希望使用完整的永久链接.
Looking for a way to export a list of pretty permalinks in WordPress with the corresponding post title. Looking for the actual permalink structure defined not the shortlink. I suppose if I have to, I will use a short link, but I prefer the full permalink.
推荐答案这是一个独立的PHP文件,您可以将其保存到网站的根目录中,称为/export.php之类,当您使用浏览器进行调用时,它将发送一个以制表符分隔的纯文本列表,其中包含漂亮的永久链接,帖子标题和(作为奖励)帖子类型.
Here's a standalone PHP file you can save into the root of your website called something like /export.php and when you call it with your browser it will send a tab-delimited plain text list of posts with the pretty permalink, the post title and (as a bonus) the post type.
只需将URL加载到浏览器中,然后将"另存为"到一个文本文件,然后可以在Excel中加载,否则您需要对其进行处理.
Just load the URL in your browser and then "save as" to a text file you can then load in Excel or however else you need to process it.
<?php include "wp-load.php"; $posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish'); $posts = $posts->posts; /* global $wpdb; $posts = $wpdb->get_results(" SELECT ID,post_type,post_title FROM {$wpdb->posts} WHERE post_status<>'auto-draft' AND post_type NOT IN ('revision','nav_menu_item') "); */ header('Content-type:text/plain'); 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{$post->post_type}\t{$permalink}\t{$post->post_title}"; }希望这会有所帮助.
-迈克
P.S.我使用了标准的WordPress WP_Query(),但还包含注释掉的SQL,以防您更喜欢(或需要)使用它.
P.S. I used the standard WordPress WP_Query() but also included a commented-out SQL in case you prefer (or need) to use it instead.
更多推荐
导出漂亮的永久链接和帖子标题列表
发布评论