Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
You can use a PHP function to display your HTML Sitemap anywhere on your site.
You can use this method if you want to use code in your WordPress theme to display the sitemap.
To learn about setting up the HTML Sitemap, check out our article on How to Create an HTML Sitemap here.
The main function to use is:
<?php if( function_exists( 'aioseo_html_sitemap' ) ) aioseo_html_sitemap(); ?>
There are also some arguments you can use to customize what is displayed.
You can see the PHP code by clicking on PHP Code in the Display HTML Sitemap section of the HTML Sitemap settings.
You can see all of the arguments by clicking on the Advanced Settings link next to the PHP code.
The arguments for the PHP code are:
- post_types – Use this to specify which post types you want displayed in the sitemap. You can list multiple post types separated by a comma. Make sure you use the slug for each post type, i.e. post, page
- taxonomies – Use this to specify which taxonomies you want displayed in the sitemap. You can list multiple taxonomies separated by a comma. Make sure you use the slug for each taxonomy, i.e. category, post_tag
- label_tag – Use this to specify the HTML tag you want to use for the labels above each section in the HTML Sitemap. The default is H4
- show_label – Use this to control whether labels are displayed above each section in the HTML Sitemap. The values are true or false, and the default is true
- publication_date – Use this to control whether the date your content was published is displayed next to each content item in the HTML sitemap. The values are true or false, and the default is true. See the documentation here for more details
- archives – Use this to control whether a compact archive is displayed instead of the HTML Sitemap. The values are true or false, and the default is true. See the documentation here for more details
- order – Use this to control the direction in which content is listed in the HTML Sitemap. The values are ASC or DESC and the default is ASC (ascending). See the documentation here for more details
- order_by – Use this to control the order in which content is listed in the HTML Sitemap. The values are publish_date, last_updated, alphabetical or id and the default is publish_date (Publish Date). See the documentation here for more details
Here’s an example of how to use these arguments:
<?php if( function_exists( 'aioseo_html_sitemap' ) ) aioseo_html_sitemap( array(
'post_types' => 'post,page',
'taxonomies' => 'category',
'label_tag' => 'span',
'show_label' => 'true',
'publication_date' => 'true',
'archives' => 'false',
'order' => 'ASC',
'order_by' => 'alphabetical'
) ); ?>