代码获取WordPress网站全部文章链接便于提交收录等简洁版

代码获取WordPress网站全部文章链接便于提交收录等简洁版插图

在网站的运营中,网络搜索引擎的爬取速度可能会慢些,所以就需要我们手动去操作提高收录率,今天给很多平台提交了一下文章。有时候想着文章太多,虽然用了sitemap但是不精准,所以还是喜欢直接提交链接 ,那样猛烈点。

食用:网站根目录新建geturl.php文件,将代全部码粘贴通过浏览器访问该文件即可(例如:域名/geturl.php),代码中也写注释可看下。

代码如下:

<?php
include ( "wp-config.php" ) ;
require_once (ABSPATH.'wp-blog-header.php');
global $wpdb;
$qianzui = "https://soujiz.com/";//网站域名
$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/>";
}
?>
<?php   
      include ( "wp-config.php" ) ; 
      require_once (ABSPATH.'wp-blog-header.php'); 
      global $wpdb; 
      $qianzui = "https://soujiz.com/";//网站域名
      $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/>";
      }
?>
<?php include ( "wp-config.php" ) ; require_once (ABSPATH.'wp-blog-header.php'); global $wpdb; $qianzui = "https://soujiz.com/";//网站域名 $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/>"; } ?>

如果你的是ID方式的话,比如:你的文章链接是这样的 https://soujiz.com/?p=4592,就使用这个代码:

<?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   
      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 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/>"; } ?>

这样你的网站的所有文章链接就可以获取到了,用于提交就方便多了。下面截取部分效果图如下:

代码获取WordPress网站全部文章链接便于提交收录等简洁版插图1
© 版权声明
THE END
喜欢点个赞支持一下吧
点赞0赏币 分享
No matter when you start, it is important not to stop after the start.
无论你在什么时候开始,重要的是开始之后就不要停止
评论交流 抢沙发

请登录后发表评论

    暂无评论内容