This logic is a PHP logic, but one wordpress function for post meta data →

 <?php
               // U need to use this to set the checked="checked"
               $checkbox_value = get_post_meta($object->ID, "meta-box-radio", true);
           ?>
                      <label>
                          <input type="radio" name="meta-box-radio" value="sidebar-rhs"<?php if($checkbox_value == 'sidebar-rhs'){echo 'checked ="checked"';} ?> /><img src="<?php echo get_template_directory_uri(); ?>/inc/admin/img/sidebar-lhs.png" width="10%" height:auto;>
                      </label>

                      <label>
                          <input type="radio" name="meta-box-radio" value="sidebar-lhs" <?php if($checkbox_value == 'sidebar-lhs'){echo 'checked ="checked"';} ?>/><img src="<?php echo get_template_directory_uri(); ?>/inc/admin/img/sidebar-rhs.png" width="10%" height:auto;>
                      </label>

                      <label>
                          <input type="radio" name="meta-box-radio" value="sidebar-none" <?php if($checkbox_value == 'sidebar-none'){echo 'checked ="checked"';} ?>/><img src="<?php echo  get_template_directory_uri(); ?>/inc/admin/img/sidebar-none.png" width="10%" height:auto;>
                      </label>
       </div>

Now what this logic does is actually it helps in selecting the Pot template.

I am using the above logic, which one true should print a extra class. This Video will show that the class is not echoing.

I am doing this →

<aside class="main-sidebar col <?php if($checkbox_value == 'sidebar-lhs') {echo 'main-sidebar-reverse'; } ?> ">
    <?php dynamic_sidebar( 'sidebar1' ); ?>
</aside>

But despite the Left hand sidebar is selected and successfully saved in WordPress this class → main-sidebar-reverse is not getting printed in the HTML.

THIS IS A WORDPRESS QUESTION, BUT BUG IS A PURE PHP RELATED THAT’S WHY I HAVE POSTED THIS HERE.

Read more here: Is my PHP Conditional Logic Incorrect or I am doing some silly mistake


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: