Your question is a bit too involved to fully answer, but the answer is it depends. If you want to use tabs in a PHP template then you can do so using the do_shortcode()
function. Basically you pass it text and it will find any shortcodes in that text and deal with it appropriately. So, for example, in your PHP template you could do:
<?php
// ...snip...
echo do_shortcode(
'[tabs]'
.'[tab title="Tab one"]'
.'Content for tab one'
.'[/tab]'
.'[/tabs]'
);
// ...snip...
?>
Then, of course, you can replace ‘Content for tab one’ with whatever you want.
Alternatively there are a number of plugins that allow you to embed PHP into your page or post’s content. See this plugin for example: http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/ Obviously there are potential security concerns around doing that, so use your common sense.
Another option that I am very fond of is to simply create a new shortcode in a separate plugin or even in your theme’s functions.php
file that does whatever it is you’re trying to achieve.
Thank you for your quick response. I think the do_shortcode is is exactly what I was looking for. Thank you.
This might be a separate topic but since I did this:
echo do_shortcode(
'[tabs title="" disabled="false" collapsible="false" active="0" event="click"]' .
'[tab title="Ministry News"]' .
$userRegion
. '[tab title="Ministry Volunteers"]Tab 1 content[/tab]' .
'[tab title="Ministry Resources"]Tab 2 content[/tab]' .
'[/tabs]'
);
The $userRegion variable is being displayed in the second tab with “Tab 1 content” and the first tab is blank. Is this my coding error or is something strange going on?
You’re missing a [/tab]
after $userRegion:
echo do_shortcode(
'[tabs title="" disabled="false" collapsible="false" active="0" event="click"]' .
'[tab title="Ministry News"]' .
$userRegion
.'[/tab]'
.'[tab title="Ministry Volunteers"]Tab 1 content[/tab]' .
'[tab title="Ministry Resources"]Tab 2 content[/tab]' .
'[/tabs]'
);
Works perfectly… thanks for helping a poor, dumb soul.