{"id":46,"date":"2022-04-26T09:59:04","date_gmt":"2022-04-26T09:59:04","guid":{"rendered":"https:\/\/tocwp.com\/docs\/?post_type=ht_kb&#038;p=46"},"modified":"2025-11-28T08:11:12","modified_gmt":"2025-11-28T08:11:12","slug":"how-to-add-a-shortcode-in-easy-table-of-contents","status":"publish","type":"ht_kb","link":"https:\/\/tocwp.com\/docs\/knowledge-base\/how-to-add-a-shortcode-in-easy-table-of-contents\/","title":{"rendered":"How to Add a Shortcode in Easy Table of Contents"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We have the option to add the TOC using the shortcode<strong>,<\/strong> with this shortcode you can easily add the TOC in the content or anywhere in WordPress and if you want to add the shortcode on the theme file then you can add it with the help of the PHP code and with this, you can add the TOC on any file according to you need.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Shortcode:- &#091;ez-toc]\nPHP Code:- &lt;?php echo do_shortcode( \u2018&#091;ez-toc]\u2019 ); ?&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:<\/strong>&nbsp;First, you need to install and activate our&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/easy-table-of-contents\/\">Easy Table of Contents<\/a>&nbsp;plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2:<\/strong>&nbsp;After that go to the&nbsp;<strong>WordPress dashboard<\/strong>&nbsp;and edit the post in which you want to display the Table of Contents on a specific Post\/Page. \u201c\u201d with this shortcode you can easily add the TOC in the content or anywhere in WordPress copy the shortcode and place where you want to display it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"418\" src=\"https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-1024x418.png\" alt=\"\" class=\"wp-image-48\" srcset=\"https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-1024x418.png 1024w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-300x123.png 300w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-768x314.png 768w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-50x20.png 50w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-60x25.png 60w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333-100x41.png 100w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-333.png 1341w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The Output of TOC with shortcode<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"386\" src=\"https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-1024x386.png\" alt=\"\" class=\"wp-image-49\" srcset=\"https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-1024x386.png 1024w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-300x113.png 300w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-768x290.png 768w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-50x19.png 50w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-60x23.png 60w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444-100x38.png 100w, https:\/\/tocwp.com\/docs\/wp-content\/uploads\/2022\/04\/a-444.png 1346w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>That\u2019s it for this tutorial!<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We hope we\u2019ve cleared your doubts in case you have any feedback or questions, then please share them in the comments section below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Or you Just contact us&nbsp;<a href=\"https:\/\/tocwp.com\/contact\/\">here<\/a>&nbsp;and we are always available for you.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have the option to add the TOC using the shortcode, with this shortcode you can easily add the TOC in the content or anywhere in WordPress and if you want to add the shortcode on the theme file then you can add it with the help of the PHP&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[4],"ht-kb-tag":[],"class_list":["post-46","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-how-to"],"_links":{"self":[{"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":9,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/46\/revisions"}],"predecessor-version":[{"id":2648,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/46\/revisions\/2648"}],"wp:attachment":[{"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=46"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/tocwp.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}