I wanted to know if there is a way for the chocolate to be directed to two different parameters? And I will explain
this shortcode [group skill] => return $skill;
This is the second shortcode [group lang] => return $lang;
I have a group that I opened through ACF and I want to take out a shortcode every time to a different place, to the place intended for it
This is the original code
<?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;
});
?>
editing:
After failed attempts, I preferred to build the design on top of HTML (previously it was built in the form of Elementor)
I have the following code:
<?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;
});
?>
The goal is to insert into this array all the shortcodes I will create in the future
That’s why I did:
<?php
$shortcode = do_shortcode('[time]');
$shortcode1 = do_shortcode('[chapters]');
?>
or for HTML:
[time]
[chapters]
But then I get stuck on the same issue of how I insert the various SHORTCODE variables
2
Answers
Many thanks to everyone who tried to help I found a nice method to combine all the shortcodes into one shortcode
Short Code Definition Class (Create the file with desired name and add the code in to the file.
Now Add the below lines to your plugin definition file
Shortcodes could be called like…