Multi-Language Code Tabs: [wpsd-tabs]
When you want to show the same example in more than one language (a curl / JavaScript / Python version of the same API call, for instance), wrap the code blocks in [wpsd-tabs] to render them as a tabbed interface instead of several stacked blocks.
Basic usage#
Add a Custom HTML block and write the shortcode around your code blocks, each with its own language- class:
[wpsd-tabs]
<pre><code class="language-bash">curl https://api.example.com/v1/docs</code></pre>
<pre><code class="language-js">fetch('https://api.example.com/v1/docs')</code></pre>
<pre><code class="language-python">requests.get('https://api.example.com/v1/docs')</code></pre>
[/wpsd-tabs]
curl https://api.example.com/v1/docs
fetch('https://api.example.com/v1/docs')
requests.get('https://api.example.com/v1/docs')
Each tab’s label comes directly from that block’s language class (“bash,” “js,” “python”). If a code block inside the tabs has no language- class, its tab is labeled “Tab 1,” “Tab 2,” and so on instead.
Minimum of two code blocks#
Tabs only render when there are at least two code blocks inside . If there’s only one, it’s shown as a normal, single code block instead, since a one-tab interface wouldn’t add anything.
Everything from Code Blocks still applies#
Each tab keeps its own copy button and syntax highlighting, exactly as described in Code Blocks: Syntax Highlighting & Copy Button. Tabs only change how the blocks are grouped and switched between, not how each individual block behaves.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!