Simple Sitemap Shortcode

Below, you’ll find a detailed guide on how to add the Simple Sitemap Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Simple Sitemap Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Simple Sitemap Plugin and the shortcodes it provides:

Plugin Icon
Simple Sitemap – Create a Responsive HTML Sitemap

"Simple Sitemap is a user-friendly WordPress plugin designed to generate a responsive HTML sitemap. This easily navigable layout enhances user experience and SEO optimization. Install Simple Sitemap for a streamlined site navigation."

★★★★✩ (66) Active Installs: 90000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [simple-sitemap-group]

Simple Sitemap [simple-sitemap-group] Shortcode

The Simple Sitemap Group shortcode in WordPress is a tool that renders a specific function when called. This shortcode calls the ‘render_shortcode’ function, which checks if the ‘attributes’ parameter is an array. If it’s not, it creates an empty array. It then sets the ‘gutenberg_block’ attribute to false, regardless of its initial state. Finally, it returns a sanitized version of the rendered attributes.

Shortcode: [simple-sitemap-group]

Examples and Usage

Basic example – The simple-sitemap-group shortcode can be used to display a categorized sitemap on your website. Here is a basic usage example:

[simple-sitemap-group /]

Advanced examples

Include specific categories in your sitemap using the ‘cat’ attribute. The categories should be identified by their IDs, separated by commas:

[simple-sitemap-group cat="1,2,3" /]

Control the order of posts within each category using the ‘orderby’ and ‘order’ attributes. The ‘orderby’ attribute determines the criteria for ordering, and the ‘order’ attribute determines the direction of the order:

[simple-sitemap-group orderby="title" order="ASC" /]

Limit the number of posts displayed within each category using the ‘posts_per_page’ attribute:

[simple-sitemap-group posts_per_page="5" /]

Exclude certain posts from the sitemap using the ‘post__not_in’ attribute. The posts should be identified by their IDs, separated by commas:

[simple-sitemap-group post__not_in="1,2,3" /]

Include only certain post types in the sitemap using the ‘post_type’ attribute. The post types should be identified by their slugs, separated by commas:

[simple-sitemap-group post_type="post,page" /]

Display posts from a specific date using the ‘date_query’ attribute. The date should be specified in the format ‘YYYY-MM-DD’:

[simple-sitemap-group date_query="2022-01-01" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [simple-sitemap-group] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'simple-sitemap-group', array( &$this, 'render_shortcode' ) );

Shortcode PHP function:

function render_shortcode( $attributes ) {

		// For a sitemap shortcode set 'gutenberg_block' to false in case it has been set to true manually.
		if ( ! is_array( $attributes ) ) {
			$attributes = array();
		}
		$attributes['gutenberg_block'] = false;
		return wp_kses_post( $this->render( $attributes ) );
	}

Code file location:

simple-sitemap/simple-sitemap/lib/classes/shortcodes/simple-sitemap-group-shortcode.php

Conclusion

Now that you’ve learned how to embed the Simple Sitemap Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *