WordPress站点一键获取所有链接

废话不说,直接上代码。[doge]

有时需要对网站所有的链接提取,使用软件获取网站链接容易出现大量的重复链接,就给大家分享一个通过一段php代码一键获取WordPress站点全站所有链接,包括page单页面,文章页面,分类页面,tag标签页面,简单,实用。[调皮]

将以下代码保存为后缀.PHP,上传至网站根目录,在浏览器中输入相应的地址就可以获取站点所有的链接了!

<?php
require('./wp-blog-header.php');
header("Content-type: text/txt");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
?>
<?php echo 'http://'.$_SERVER['HTTP_HOST']; ?><?php echo "\n"; ?>
<?php
/* 文章页面 */
header("Content-type: text/txt");
$myposts = get_posts( "numberposts=" . $posts_to_show );
foreach( $myposts as $post ) {
the_permalink();
echo "\n";
}
?>
<?php
/* 单页面 */
$mypages = get_pages();
if(count($mypages) > 0) {
foreach($mypages as $page) {
echo get_page_link($page->ID);
echo "\n";
}
}
?>
<?php
/* 博客分类 */
$terms = get_terms('category', 'orderby=name&hide_empty=0' );
$count = count($terms);
if($count > 0){
foreach ($terms as $term) {
echo get_term_link($term, $term->slug);
echo "\n";
}
}
?>
<?php
/* 标签(可选) */
$tags = get_terms("post_tag");
foreach ( $tags as $key => $tag ) {
$link = get_term_link( intval($tag->term_id), "post_tag" );
if ( is_wp_error( $link ) ) {
return false;
$tags[ $key ]->link = $link;
}
echo $link;
echo "\n";
}
?>

 

上一篇 最新可用西瓜水印在线解析源码
下一篇 移动光猫超级管理员后台
文章列表
1 知乎/百度/微博热搜PHP源码
知乎/百度/微博热搜PHP源码
2
ChatGPT全新账号购买方法
ChatGPT全新账号购买方法
3
屏蔽wordpress RSS订阅Feed接口代码
屏蔽wordpress RSS订阅Feed接口代码
4
Beyond Compare v4.3.6破解版
Beyond Compare v4.3.6破解版
5
PHP随机风景图片接口源码
PHP随机风景图片接口源码
大米酱

大米酱管理员

三百六十行,行行出BUG。

本月创作热力图

最新评论
2067608730
2067608730
4月11日
加油大米!quantou
评论于APINEXT