我想知道是否有一种方法可以让巧克力有两个不同的参数?我会解释的
此简码[组技能]=〉return $skill;
这是第二个简码[group lang]=〉return $lang;
我有一个通过ACF打开的组,我想每次都取出一个短码到不同的地方,到它的目的地
- 这是原始代码**
<?php
add_shortcode('group', function ($atts) {
$group_field = get_field('info_global_course');
if ($group_field):
$attributes = shortcode_atts([
'level_skill' => $group_field[level_skill],
'lang' => $group_field[lang],
'if_id_true' => $group_field[if_id_true]
], $atts);
/* I thought about this way, maybe it's not a rally, but maybe it will give you an idea to help me a little
* return $attributes['level_skill'];
* return $attributes['lang'];
*/
endif;
});
?>
- 编辑:在尝试失败后,我倾向于在HTML之上构建设计(以前它是以Elementor**的形式构建的)
下面的代码:
<?php
/*************************************
* Returns the values from a certain group of the post
*************************************/
add_shortcode('group', function ($atts,$shortcode_twoo,$shortcode_three) {
$group_field = get_field('info_global_course');
if ($group_field):
$attributes = shortcode_atts([
'level_skill' => $group_field[level_skill],
'lang' => $group_field[lang],
'if_id_true' => $group_field[if_id_true]
], $atts);
return '
<div>
<div class="level_skill border_bottom">
<span class="box_left"><i aria-hidden="true" class="far fa-clock"></i> time </span>
<span class="box_right">'.$shortcode .'</span>
</div>
<div class="video border_bottom">
<span class="box_left"><i aria-hidden="true" class="fas fa-video"></i> Study chapters </span>
<span class="box_right">'.$shortcode1.'</span>
</div>
<div class="studants border_bottom">
<span class="box_left"><i aria-hidden="true" class="fas fa-user-graduate"></i> Registered students</span>
<span class="box_right">100</span>
</div>
<div class="level_skill border_bottom">
<span class="box_left"><i aria-hidden="true" class="fab fa-superpowers"></i> level skill</span>
<span class="box_right">מתקדמים</span>
</div>
<div class="lang border_bottom">
<span class="box_left"><i aria-hidden="true" class="fas fa-globe"></i>language</span>
<span class="box_right">עברית</span>
</div>
<div class="if_id_true border_bottom">
<span class="box_left"><i aria-hidden="true" class="fas fa-sticky-note"></i> Diploma</span>
<span class="box_right">כן</span>
</div>
</div>
';
endif;
});
?>
目标是将我将来创建的所有短代码插入到该数组中
"所以我才这么做"
<?php
$shortcode = do_shortcode('[time]');
$shortcode1 = do_shortcode('[chapters]');
?>
- 或HTML:**[时间][章节]
但是,我又陷入了如何插入各种SHORTCODE变量的同一个问题
2条答案
按热度按时间lmvvr0a81#
短代码定义类(创建具有所需名称的文件,并将代码添加到文件中。
现在将下面几行添加到插件定义文件中
简码可以叫做...
noj0wjuj2#
非常感谢大家谁试图帮助我找到了一个很好的方法来合并所有的短代码成一个短代码