Is there a solution to add tabs at the whole site (site-wide) and not just in posts and pages?

For example:

I need one "tabs group" consisted of 3 tabs, and I like to add it sitewide (the same content / tabs at all pages and posts; like menu / submenu but with tabs functionality). Is this possible?

Otherwise, it's a lot of work to add the same "tabs group" to all pages and posts one by one.


Depends on where you want it, but the first thing that comes to mind is to simply add it in either header.php or footer.php in your theme. This is especially simple if the content won't change often - just add the code to your theme files.

If it's content you want to change often, then you want to add a widget area to the theme template file where you want the tabs to appear.

in functions.php, we'll register the sidebar:

so you'll be able to add widgets to it the Wordpress control panel via appearance > widgets

function addTabsArea() {
    'name' => 'Tabs Area',
    'id' => 'sidebar-tabs',
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_widget' => '</h3>'
} add_action('init', 'addTabsArea');

in your template file, add the code to render the sidebar

(header.php, footer.php, page.php, single.php wherever you need it):

<ul class="tabs-area">
  <?php dynamic_sidebar('sidebar-tabs'); ?>

Now you can go to Appearance > Widgets, add any widget you like (in this case a single instance of a jquery tabs widget/plugin of your choice) to that new "sidebar", and that content will appear wherever you placed it in your theme file. A bit of css and you should be all set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.