将 PHP 代码插入 Visual Composer
Insert PHP code into the Visual Composer
我有 php 代码(ACF Pro 插件代码)。如何将此代码插入我的 Visual Composer?很长一段时间都找不到解决方案,但现在对我来说很关键。
<?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; ?>
由于 if & while 条件,我无法通过短代码实现它。 Row HTML 和 Row JS 对我也没用。
只需将您的 php 代码放入函数中并创建短代码
function vComp(){
**PHP CODE**
}
add_shortcode( 'vShortcode', 'vComp' );
转到 Visual Composer- Shortcode Mapper - Map Shortcode - 然后输入有效的简码(示例:[vShortcode])。
在 functions.php 页中创建函数。
function shortcode (){
}
add_shortcode('shortcode-name',shortcode );
我有 php 代码(ACF Pro 插件代码)。如何将此代码插入我的 Visual Composer?很长一段时间都找不到解决方案,但现在对我来说很关键。
<?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; ?>
由于 if & while 条件,我无法通过短代码实现它。 Row HTML 和 Row JS 对我也没用。
只需将您的 php 代码放入函数中并创建短代码
function vComp(){
**PHP CODE**
}
add_shortcode( 'vShortcode', 'vComp' );
转到 Visual Composer- Shortcode Mapper - Map Shortcode - 然后输入有效的简码(示例:[vShortcode])。
在 functions.php 页中创建函数。
function shortcode (){
}
add_shortcode('shortcode-name',shortcode );