php Yoast SEO | HTML站点地图

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Yoast SEO | HTML站点地图相关的知识,希望对你有一定的参考价值。

<h2 id='authors'>Authors</h2>
<ul>
<?php
wp_list_authors(
  array(
    'exclude_admin' => false,
  )
);
?>
</ul>

<h2 id='pages'>Pages</h2>
<ul>
<?php
// Add pages you'd like to exclude in the exclude here
wp_list_pages(
  array(
    'exclude' => '',
    'title_li' => '',
  )
);
?>
</ul>

<h2 id='posts'>Posts</h2>
<ul>
<?php
// Add categories you'd like to exclude in the exclude here
$cats = get_categories('exclude=');
foreach ($cats as $cat) {
  echo '<li><h3>'.$cat->cat_name.'</h3>';
  echo '<ul>';
  query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
  while(have_posts()) {
    the_post();
    $category = get_the_category();
    // Only display a post link once, even if it's in multiple categories
    if ($category[0]->cat_ID == $cat->cat_ID) {
      echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    }
  }
  echo '</ul>';
  echo '</li>';
}
?>
</ul>

<?php // Custom Post Type Support
foreach( get_post_types( array('public' => true) ) as $post_type ) {
  if ( in_array( $post_type, array('post','page','attachment') ) )
    continue;

  $pt = get_post_type_object( $post_type );

  echo '<h2>'.$pt->labels->name.'</h2>';
  echo '<ul>';

  query_posts('post_type='.$post_type.'&posts_per_page=-1');
  while( have_posts() ) {
    the_post();
    echo '<li><a href='.get_permalink().'>'.get_the_title().'</a></li>';
  }

  echo '</ul>';
} ?>

以上是关于php Yoast SEO | HTML站点地图的主要内容,如果未能解决你的问题,请参考以下文章

php 将IDX站点地图添加到Yoast SEO站点地图

php Yoast SEO站点地图的过滤器和示例代码

php Wordpress yoast seo插件,为自定义URL生成自定义站点地图

php Wordpress yoast seo插件,为自定义URL生成自定义站点地图

使用Yoast SEO提交Sitemap

php 删除WordPress中的[All in One SEO Pack]或[Yoast SEO] HTML评论(适用于functions.php)