将PHP代码插入Visual Composer [英] Insert PHP code into the Visual Composer
本文介绍了将PHP代码插入Visual Composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有php代码(ACF Pro插件代码)。如何将此代码插入Visual Composer?很长一段时间找不到解决方案,但现在对我来说至关重要。
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; ?>
由于if&条件。行HTML和行JS对我也没有用。
I can't realize it via shortcodes because of if & while conditions. Row HTML and Row JS are useless for me as well.
推荐答案
只需将您的php代码放入函数中并创建简码
Just put your php code inside a function and create shortcode
function vComp(){
**PHP CODE**
}
add_shortcode( 'vShortcode', 'vComp' );
转到Visual Composer-简码映射器-映射简码-然后输入有效的简码(例如:[vShortcode])
Goto Visual Composer- Shortcode Mapper - Map Shortcode - then Enter valid shortcode (Example: [vShortcode]).
这篇关于将PHP代码插入Visual Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文