Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:36:00+00:00 2026-06-07T22:36:00+00:00

I have inserted a set of tabs to my php wordpress template using the

  • 0

I have inserted a set of tabs to my php wordpress template using the following shortcodes

    <?php echo do_shortcode('[tabs style="boxed"]
            [tab title="1"][some content here][/tab]
            [tab title="2"]' . get_the_excerpt() . '[/tab]
            [/tabs]');  ?>

This works fine.

I have created 2 x custom checkbox fields called ‘tab_contact_1’ and ‘tab_contact_2’ in a custom post.

I would like to add conditional logic to the tabs so that if the checkbox is true/checked the tab shows. If not it hides. (This is due to some posts having this content available and some not)

I have similar logic working for other custom fields on the site, but not using tabs and was thinking I can apply the same mindset. I took a go at the code (see below) but the page is not loading. I am doing something wrong but can’t figure it out. Was hoping for some guidance.

thanks a lot

<?php echo do_shortcode('[tabs style="boxed"]
' . if ( get_post_meta($post->ID, 'tab_contact_1', true)) { . '
[tab title="1"][some content here][/tab]
'. } .'
' . if ( get_post_meta($post->ID, 'tab_contact_2', true)) { . '
[tab title="2"]' . get_the_excerpt() . '[/tab]
'. } .'
[/tabs]');  ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:36:02+00:00Added an answer on June 7, 2026 at 10:36 pm

    Good practice is not to echo single lines, but to store them in a variable and echo out the finaly code like this:

    <?php
    
    $result = '';
    
    $result .= '[tabs style="boxed"]';
    if ( get_post_meta( $post->ID, 'tab_contact_1', true ) != 'false' ) {
        $result .= '[tab title="1"][some content here][/tab]';
    }
    if ( get_post_meta( $post->ID, 'tab_contact_2', true ) != 'false' ) {
        $result .= '[tab title="2"]' . get_the_excerpt() . '[/tab]';
    }
    $result .= '[/tabs]';
    
    echo do_shortcode( $result );
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inserted the following line into my Joomla template: <jdoc:include type=component /> This
i am using a website application for registration, in that application i have inserted
I have inserted some data in table using encryption (encrypted by creating my own
I have the following code: self.sliderR.Bind(wx.EVT_SCROLL,self.OnSlide) In the function OnSlide I have the inserted
I'm using a stl::set to keep elements sorted as they are inserted. My question
This example is simplified. I have the following design: http://img835.imageshack.us/i/designyi.jpg/ I have inserted test
I have inserted an image in the view.No I need to set an animation
I have inserted string and integer values into dynamic columns in a Cassandra Column
I have inserted this form with multiple checkbox items which collects some values, What
I have inserted a code to display product attribute in view.phptml, which works fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.