Dragon

获取wordpress全站文章链接教程

2020-11-11 21:19 46 抢沙发 小王总博客

我们在使用各大站长的平台的时候,往往想提交全站链接,但是汇总它们却很困难。今天小逸给大家分享一段可以汇总全站文章链接的代码

复制这段代码,然后保存为rul.php,上传至网站根目录,然后访问域名/rul.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"; } 
 ?>


获取wordpress全站文章链接教程

「点点赞赏,手留余香」

还没有人赞赏,快来当第一个赞赏的人吧!

小王总给小王总打赏
×
予人玫瑰,手有余香
  • 2
  • 5
  • 10
  • 20
  • 50
2
支付

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

2020-11-06

2020-11-11

发表评论

表情 格式 贴图 链接 私密 签到 常用语
请选择评论常用语:
1、支持一下博主!
2、对我非常有帮助!
扫一扫二维码分享