Shortcodes and template tags
Add RankKit SEO breadcrumbs, business details and store lists to posts and theme templates with shortcodes and the speedrank_breadcrumbs() template tag.
On this page
RankKit SEO has three shortcodes and one PHP template tag for placing its output in content and theme templates. For FAQ, How-to and table of contents sections, use the blocks instead.
| Name | Type | Edition |
|---|---|---|
[speedrank_breadcrumbs] |
Shortcode | Free |
speedrank_breadcrumbs() |
PHP template tag | Free |
[speedrank_local] |
Shortcode | Free (the location attribute needs Pro) |
[speedrank_locations] |
Shortcode | Pro |
Breadcrumbs
Shortcode
[speedrank_breadcrumbs]
Prints the breadcrumb trail for the current page. It takes no attributes. The shortcode is available while the breadcrumbs module is on, which it is by default.
Template tag
<?php
if ( function_exists( 'speedrank_breadcrumbs' ) ) {
speedrank_breadcrumbs();
}
?>
Add it to a theme template, for example above the title in single.php. The function_exists() check keeps the theme working if RankKit SEO is ever deactivated.
speedrank_breadcrumbs( $echo = true ) prints the trail. Pass false to get the HTML back as a string instead:
$crumbs = function_exists( 'speedrank_breadcrumbs' ) ? speedrank_breadcrumbs( false ) : '';
Output
Both print the same markup:
<nav class="speedrank-breadcrumbs" aria-label="Breadcrumb">
<a href="https://example.com/">Home</a>
<span class="sep" aria-hidden="true">›</span>
<a href="https://example.com/category/guides/">Guides</a>
<span class="sep" aria-hidden="true">›</span>
<span aria-current="page">How to choose trail shoes</span>
</nav>
The trail runs from Home through the blog page, the post's primary category (with its parent categories) or parent pages, to the current page. Nothing is printed on the home page, where the trail has only one item. Style it with the .speedrank-breadcrumbs class.
The same trail is used for BreadcrumbList schema, so search engines see it whether or not you display it. To change the items, use the speedrank_breadcrumbs filter (see Hooks and filters). There is no breadcrumbs block. More in Breadcrumbs.
Business details
[speedrank_local show="name,address,phone,email,hours,map"]
Prints your business details from RankKit SEO → Settings → Local SEO.
| Attribute | Default | What it does |
|---|---|---|
show |
name,address,phone,email,hours,map |
Which parts to print, comma-separated. Any of: name, address, phone, email, hours, map. |
location |
(empty: the main business) | With RankKit SEO Pro and multiple locations, the ID of the location to show. |
The shortcode prints nothing until Local SEO is turned on and the site is set up as an organization. The Business info (RankKit SEO) block shows the same details in the block editor. See Local SEO.
Store list (Pro)
[speedrank_locations city="Berlin" show="name,address,phone,map"]
Lists your business locations (RankKit SEO Pro, with multiple locations turned on in Settings → Local SEO).
| Attribute | Default | What it does |
|---|---|---|
city |
(empty: all locations) | Only list locations in this city. |
show |
name,address,phone,map |
Which parts to print for each location. The name is always shown. |
The output is a <ul class="speedrank-locations"> list. The Store list (RankKit SEO) block does the same in the block editor.
FAQ
Do I need the shortcode for breadcrumb schema?
No. RankKit SEO adds BreadcrumbList schema on its own. The shortcode and template tag only display the trail to visitors.
Can I use the breadcrumbs in a block theme?
Block themes don't use PHP templates, so add the [speedrank_breadcrumbs] shortcode with a Shortcode block in the Site Editor.
Which category does the trail use when a post has several?
The primary category, if one is set. Otherwise the first category WordPress returns for the post.
Was this page helpful?
Related guides
Breadcrumbs
Show a breadcrumb trail with the [speedrank_breadcrumbs] shortcode or a PHP template tag, and get matching BreadcrumbList schema on every page.
Local SEO
Add LocalBusiness schema with your address, map position, phone and opening hours, show them on your site and publish a KML file, all with RankKit SEO.
FAQ, How-to and Table of contents blocks
Add FAQ, How-to and Table of contents blocks that output FAQPage, HowTo and navigation schema, with no JavaScript and a tiny stylesheet.
Hooks and filters
Every public RankKit SEO action and filter, with its parameters and what it changes, plus PHP examples for head tags, schema, llms.txt and agent tools.
Still need help?
Email us with your WordPress and RankKit SEO versions and what you tried. Pro customers get priority replies.