填一下以前文章中提到的WordPress获取所有文章链接的坑。
使用方法
- 在以下的PHP代码中选择一个复制
- 新建GetId.php文件,将代全部码粘贴
- 将GetId.php文件上传至
网站根目录
- 通过浏览器访问该文件即可(例如:www.qcgzxw.cn/GetId.php)
- 显示内容即为所有已发布的文章链接,复制后保存至本地即可(文件使用完毕后记得删了)
PHP代码
1.获取所有已发布文章(ID)
文章链接:https://www.qcgzxw.cn/2579.html
红色字体即为前缀,绿色即为后缀
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php include ( "wp-config.php" ) ; require_once (ABSPATH.'wp-blog-header.php'); global $wpdb; $qianzui = "https://www.qcgzxw.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)
缺点:只能显示原始链接
1 2 3 4 5 6 7 8 9 10 |
<?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/>"; } ?> |
3.获取分类下所有文章
1 2 3 4 5 6 7 8 9 10 11 |
<?php include ( "wp-config.php" ) ; require_once (ABSPATH.'wp-blog-header.php'); global $wpdb; $CID = 1;//分类id $sql="SELECT ID,post_title,post_content FROM wp_posts,wp_term_relationships,wp_term_taxonomy WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy = 'category' order by ID desc"; $myrows = $wpdb->get_results($sql); foreach ($myrows as $b) { echo $b->ID."<br />"; } ?> |
玩法介绍
- 批量查询文章是否被收录(筛选出未收录的链接)http://www.link114.cn/baidusl/未被收录的文章链接批量提交百度
-
更多玩法持续更新中···
5b3554f9879db90711281c90b6859603 很好
这个好,方便。
可以根据数据库结构,写出对应的SQL语句来实现各种功能的