WordPress获取当前网站所有的文章链接

使用步骤

1.新建geturl.php文件,将代全部码粘贴
2.将geturl.php文件上传至网站根目录
3.通过浏览器访问该文件即可(例如:域名/geturl.php)
4.显示内容即为所有已发布的文章链接,复制后保存至本地即可(文件使用完毕后记得删了)

获取所有已发布文章(ID)【静态链接】

文章链接:https://ludongdong.com/660.html

红色字体即为前缀,绿色即为后缀

代码

<?php   
      include ( "wp-config.php" ) ; 
      require_once (ABSPATH.'wp-blog-header.php'); 
      global $wpdb; 
      $qianzui = "http://blog.smoxo.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/>";
      }
?>

访问【域名/geturl.php】就可以看到网站所有文章的URL链接了

获取所有已发布文章(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/>"; 
      }
?>

访问【域名/geturl.php】

适用于搜索引擎的提交、网站采集等场景

文章来源:

Author:卢东东
link:https://ludongdong.com/275.html