How to Embed Tabs using Template Tag

You can use WordPress Post Tabs Template Tag to embed the tabs created in a template file, so that every time when the page using that template file loads, the tabs are displayed. This will reduce the duplicate effort of embedding the tabs (if the tabset you created is going to remain the SAME) using the shortcodes on each and every pages and it will also help using tabs on Main Index page and other blog archive pages as well.

Watch the below Video:


Go thru the Quick Steps below:

Step 1

  • Go to “Custom Tabs” Admin Menu
  • Add a New “Custom Tab”
  • Enter the Title for Custom Tab
  • Go to “Visual” Editor
  • Click on Tabs PRO Quicktag
Add new Custom Tab

Add new Custom Tab

Step 2

  • Enter all the names of the ‘Tabs’ that you want to create
  • Select the ‘Tabs’ Skin
Enter Tab Names

Enter Tab Names

Step 3

  • Once you Select Skin, you will get to select the Tabs options specific to that Skin
  • Select effect, easing, enable Navigation and set many other attributes
  • Click on “Insert” button
Insert Shortcode

Insert Shortcode

Step 4

  • Once you click on “Insert” button, on the Post Editor, you will see the Tabs shortcode generated for you.
  • You just need to add the content for each tab. You can add Text, Images, Videos or any other Shortcode
Add Content to the Tabs

Add Content to the Tabs

Step 5

  • Publish the “Custom Tab”
  • Note the Post ID / ID of the Custom Tab, the screenshot here shows the post ID as 11
Get Post ID of the Custom Tab

Get Post ID of the Custom Tab

Step 6

  • Go to the “theme template file” in which you want to embed the Tabs ( e.g. index.php / page.php / single.php etc. )
  • Paste the below template tag in the location where you want to display the tabs
<?php if ( function_exists( 'get_custom_wordpress_post_tabs' ) ) { get_custom_wordpress_post_tabs($post_id); } ?>

where $post_id is the ID of the Custom Tab we just noted (11 in our case)

 For example, the template tag would be

<?php if ( function_exists( 'get_custom_wordpress_post_tabs' ) ) { get_custom_wordpress_post_tabs($post_id='11'); } ?>
Paste the template tag in template file

Paste the template tag in template file

Step 7

  • If you are using the template tag on Archives and Index page, you will need to enable the “Tabs” Site-wide. By default, the tabs feature is enabled only on Single Posts and Pages
  • Go to “Tabs PRO” menu ==> Enter “tick” for “Enter tabs Sitewide” Settings option ==> Save the Settings
Enable tabs Sitewide

Enable tabs Sitewide

Step 8

Open the page using the template file and find your awesome tabs on all the pages using that template.