释放双眼,带上耳机,听听看~!
使用方法
- 在以下的PHP代码中选择一个复制
- 新建url.php文件,将代全部码粘贴
- 将url.php文件上传至
网站根目录 - 通过浏览器访问该文件即可(例如:https://028.sevenit.cn/url.php)
- 显示内容即为所有已发布的文章链接,复制后保存至本地即可(文件使用完毕后记得删了)
PHP代码
1.获取所有已发布文章(ID)
文章链接:https://028.sevenit.cn/6647.html
<?php
include ( "wp-config.php" ) ;
require_once (ABSPATH.'wp-blog-header.php');
global $wpdb;
$qianzui = "https://028.sevenit.cn";//填你的前缀
$houzui = ".html";//填你的后缀
$sql="SELECT ID FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY ID DESC ";
$myrows = $wpdb->get_results($sql);
foreach ($myrows as $b) {
echo $qianzui;
echo $b->ID;
echo $houzui."<br/>";
}
?>

2.获取所有已发布文章(guid)
缺点:只能显示原始链接
<?php
include ( "wp-config.php" ) ;
require_once (ABSPATH.'wp-blog-header.php');
global $wpdb;
$sql="SELECT guid FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY ID DESC ";
$myrows = $wpdb->get_results($sql);
foreach ($myrows as $b) {
echo $b->guid."<br/>";
}
?>

我目前使用的代码
<?php
require('./wp-blog-header.php');
header("Content-type: text/txt");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
?>
<?php echo 'https://'.$_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";
}
?>
MIP版本所有链接代码
<?php
require('./wp-blog-header.php');
header("Content-type: text/txt");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
?>
<?php echo 'https://'.$_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 "/mip\n";
}
?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
版权申明:网站字体及图片来源于互联网,如果侵犯了您的权利,请联系我们,我们将尽快改正我们的错误,谢谢您的理解!
