1

I have the php code (ACF Pro plugin code). How can I insert this code into my Visual Composer? Can't find the solution for a long time but now it's critical for me.

<?php if( have_rows('add_a_new_table') ): ?>
    <?php 
    while( have_rows('add_a_new_table') ): 
        the_row(); 
        // vars
        $t_title         = get_sub_field('t_title');
        $t_pricing       = get_sub_field('t_pricing');
        $t_emails_number = get_sub_field('t_emails_number');
    ?>       
        <div class="col-sm-12 col-sm-4 text-center">
            <div class="courses-column">      
                <div class="courses-column-inner">
                    <h3><?php echo $t_title; ?></h3>
                    <p style="font-size: 24px;">
                        <?php echo $t_pricing; ?>
                    </p>
                    <br>
                    <p style="font-size: 16px;">
                        <?php echo $t_emails_number; ?>    
                    </p>
                </div>
            </div>
        </div>

    <?php endwhile; ?>
<?php endif; ?> 

I can't realize it via shortcodes because of if & while conditions. Row HTML and Row JS are useless for me as well.

Stanimir Stoyanov
  • 1,876
  • 1
  • 15
  • 20
Morgari
  • 524
  • 2
  • 8
  • 24

2 Answers2

14

Just put your php code inside a function and create shortcode

function vComp(){
**PHP CODE**
 }
add_shortcode( 'vShortcode', 'vComp' );

Goto Visual Composer- Shortcode Mapper - Map Shortcode - then Enter valid shortcode (Example: [vShortcode]).

Chinou
  • 461
  • 1
  • 5
  • 23
3

Create function in functions.php page .

function shortcode (){
}
add_shortcode('shortcode-name',shortcode );