Below, you’ll find a detailed guide on how to add the Rank Math SEO 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 Rank Math SEO Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Rank Math SEO Plugin and the shortcodes it provides:
"Rank Math SEO is an innovative, powerful WordPress plugin designed to optimize your website's SEO. It enhances visibility, improves ranking, and boosts your site's overall performance."
- [ rank_math_html_sitemap]
Rank Math SEO Shortcode
The Rank Math HTML Sitemap shortcode is a tool that generates an HTML sitemap on your WordPress site. This shortcode calls the ‘shortcode’ function which in turn retrieves the HTML sitemap output. This simplifies site navigation for users and enhances SEO performance.
Shortcode: [ rank_math_html_sitemap ]
Examples and Usage
Basic example – A simple way to use the rank_math_html_sitemap shortcode to generate a sitemap on a page or post.
[ rank_math_html_sitemap /]
Advanced examples
Using the shortcode with a custom post type parameter. This will generate a sitemap only for the specified custom post type, in this case, ‘products’.
[ rank_math_html_sitemap post_type='products' /]
Using the shortcode with multiple parameters. This example will generate a sitemap for the ‘products’ custom post type and exclude the posts with the IDs 10, 20, and 30.
[ rank_math_html_sitemap post_type='products' exclude='10,20,30' /]
Using the shortcode with the ‘include’ parameter. This will generate a sitemap only for the posts with the IDs 10, 20, and 30.
[ rank_math_html_sitemap include='10,20,30' /]
Please note that the ‘include’ and ‘exclude’ parameters cannot be used together in the same shortcode. If they are, ‘exclude’ will be ignored.
PHP Function Code
In case you have difficulties debugging what causing issues with [ rank_math_html_sitemap]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'rank_math_html_sitemap', [ $this, 'shortcode' ] );
Shortcode PHP function:
function shortcode() {
return $this->get_output();
}
Code file location:
seo-by-rank-math/seo-by-rank-math/includes/modules/sitemap/html-sitemap/class-sitemap.php
Conclusion
Now that you’ve learned how to embed the Rank Math SEO 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.
Leave a Reply