0 0 0

快速获取网站全部链接 教程技术

白小纯 站长 V
2025-04-20 89

首先在你的网站根目录新建一个空白文件xx.php,我这边是创建geturl.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";

}

?>
 
PHP

访问你的https://你的域名/geturl.php即可


下载声明

每次下载将扣除 1 个经验,经验可通过 /发布主题/签到/回帖/获得!
拥有经验  :排行
拥有金币  :
兑换
拥有现金  :  0充值
关闭
最新回复 (0)

    暂无评论

请先登录后发表评论!

返回
请先登录后发表评论!