How can I add multiple shortcodes inside an ACF repeater?Calling WordPress get_template_part from inside a shortcode function renders template firstHow to Use AJAX in a WordPress Shortcode?How to echo shortcodes within shortcodes within shortcodesShortcode is moving the_content outside of the article container in WordPressinsert multiple shortcodes within a shortcode wordpressWordpress shortcode to get next post in taxonomy returns nothingHow to do a shortcode for a while loop with php?Toggle Show/Hide Configuration on Mobile - ACF RepeaterHow to add custom shortcode to WPBakery Visual Composer?How can I register in WordPress every record from a database table as a shortcode
Smoothness of finite-dimensional functional calculus
What are the differences between the usage of 'it' and 'they'?
LaTeX closing $ signs makes cursor jump
Collect Fourier series terms
Test if tikzmark exists on same page
Why does Kotter return in Welcome Back Kotter?
What's the point of deactivating Num Lock on login screens?
How to find program name(s) of an installed package?
What typically incentivizes a professor to change jobs to a lower ranking university?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
How does one intimidate enemies without having the capacity for violence?
Which models of the Boeing 737 are still in production?
What do you call a Matrix-like slowdown and camera movement effect?
Theorems that impeded progress
Python: next in for loop
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.
How is it possible to have an ability score that is less than 3?
Why do falling prices hurt debtors?
Risk of getting Chronic Wasting Disease (CWD) in the United States?
What does "Puller Prush Person" mean?
Email Account under attack (really) - anything I can do?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
What does it mean to describe someone as a butt steak?
How can I add multiple shortcodes inside an ACF repeater?
Calling WordPress get_template_part from inside a shortcode function renders template firstHow to Use AJAX in a WordPress Shortcode?How to echo shortcodes within shortcodes within shortcodesShortcode is moving the_content outside of the article container in WordPressinsert multiple shortcodes within a shortcode wordpressWordpress shortcode to get next post in taxonomy returns nothingHow to do a shortcode for a while loop with php?Toggle Show/Hide Configuration on Mobile - ACF RepeaterHow to add custom shortcode to WPBakery Visual Composer?How can I register in WordPress every record from a database table as a shortcode
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
My code is this:
<?php
function get_toggle_title()
return get_sub_field('toggle_title');
;
if( have_rows('toggle_titles') ):
$i = 1;
while( have_rows('toggle_titles') ): the_row();
add_shortcode('toggles-title-'.$i, 'get_toggle_title');
$i++;
endwhile;
endif;
?>
....but it doesn't seem to work. It's repeating the same content for each separate shortcode: [toggles-title-1], [toggles-title-2] and so on.
wordpress advanced-custom-fields shortcode wordpress-shortcode acfpro
add a comment |
My code is this:
<?php
function get_toggle_title()
return get_sub_field('toggle_title');
;
if( have_rows('toggle_titles') ):
$i = 1;
while( have_rows('toggle_titles') ): the_row();
add_shortcode('toggles-title-'.$i, 'get_toggle_title');
$i++;
endwhile;
endif;
?>
....but it doesn't seem to work. It's repeating the same content for each separate shortcode: [toggles-title-1], [toggles-title-2] and so on.
wordpress advanced-custom-fields shortcode wordpress-shortcode acfpro
add a comment |
My code is this:
<?php
function get_toggle_title()
return get_sub_field('toggle_title');
;
if( have_rows('toggle_titles') ):
$i = 1;
while( have_rows('toggle_titles') ): the_row();
add_shortcode('toggles-title-'.$i, 'get_toggle_title');
$i++;
endwhile;
endif;
?>
....but it doesn't seem to work. It's repeating the same content for each separate shortcode: [toggles-title-1], [toggles-title-2] and so on.
wordpress advanced-custom-fields shortcode wordpress-shortcode acfpro
My code is this:
<?php
function get_toggle_title()
return get_sub_field('toggle_title');
;
if( have_rows('toggle_titles') ):
$i = 1;
while( have_rows('toggle_titles') ): the_row();
add_shortcode('toggles-title-'.$i, 'get_toggle_title');
$i++;
endwhile;
endif;
?>
....but it doesn't seem to work. It's repeating the same content for each separate shortcode: [toggles-title-1], [toggles-title-2] and so on.
wordpress advanced-custom-fields shortcode wordpress-shortcode acfpro
wordpress advanced-custom-fields shortcode wordpress-shortcode acfpro
asked Mar 21 at 23:48


BlueFishBlueFish
215
215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I have a solution. This is the PHP code:
/** Create toggles Shortcodes */
function do_toggles_shortcode($atts)
$atts = shortcode_atts( array(
'number' => 1
), $atts );
ob_start();
if( function_exists('get_field') ):
if( have_rows('toggle_blocks') ):
$i = 1;
while( have_rows('toggle_blocks') ): the_row();
if( $atts['number'] == $i )
if( have_rows('toggles') ):
?>
<div class="toggles">
<?php
while ( have_rows('toggles') ) : the_row();
?>
<div class="toggle_container">
<div class="toggle_title">
<?php the_sub_field('toggle_title'); ?>
<i class="fas fa-chevron-right"></i>
</div>
<div class="toggle_content">
<?php the_sub_field('toggle_content'); ?>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif;
$i++;
endwhile;
endif;
endif;
return ob_get_clean();
add_shortcode('toggles-shortcode', 'do_toggles_shortcode');
And this is how the shortcodes look like:
[toggles-shortcode number="1"]
[toggles-shortcode number="2"]
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290871%2fhow-can-i-add-multiple-shortcodes-inside-an-acf-repeater%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have a solution. This is the PHP code:
/** Create toggles Shortcodes */
function do_toggles_shortcode($atts)
$atts = shortcode_atts( array(
'number' => 1
), $atts );
ob_start();
if( function_exists('get_field') ):
if( have_rows('toggle_blocks') ):
$i = 1;
while( have_rows('toggle_blocks') ): the_row();
if( $atts['number'] == $i )
if( have_rows('toggles') ):
?>
<div class="toggles">
<?php
while ( have_rows('toggles') ) : the_row();
?>
<div class="toggle_container">
<div class="toggle_title">
<?php the_sub_field('toggle_title'); ?>
<i class="fas fa-chevron-right"></i>
</div>
<div class="toggle_content">
<?php the_sub_field('toggle_content'); ?>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif;
$i++;
endwhile;
endif;
endif;
return ob_get_clean();
add_shortcode('toggles-shortcode', 'do_toggles_shortcode');
And this is how the shortcodes look like:
[toggles-shortcode number="1"]
[toggles-shortcode number="2"]
add a comment |
I have a solution. This is the PHP code:
/** Create toggles Shortcodes */
function do_toggles_shortcode($atts)
$atts = shortcode_atts( array(
'number' => 1
), $atts );
ob_start();
if( function_exists('get_field') ):
if( have_rows('toggle_blocks') ):
$i = 1;
while( have_rows('toggle_blocks') ): the_row();
if( $atts['number'] == $i )
if( have_rows('toggles') ):
?>
<div class="toggles">
<?php
while ( have_rows('toggles') ) : the_row();
?>
<div class="toggle_container">
<div class="toggle_title">
<?php the_sub_field('toggle_title'); ?>
<i class="fas fa-chevron-right"></i>
</div>
<div class="toggle_content">
<?php the_sub_field('toggle_content'); ?>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif;
$i++;
endwhile;
endif;
endif;
return ob_get_clean();
add_shortcode('toggles-shortcode', 'do_toggles_shortcode');
And this is how the shortcodes look like:
[toggles-shortcode number="1"]
[toggles-shortcode number="2"]
add a comment |
I have a solution. This is the PHP code:
/** Create toggles Shortcodes */
function do_toggles_shortcode($atts)
$atts = shortcode_atts( array(
'number' => 1
), $atts );
ob_start();
if( function_exists('get_field') ):
if( have_rows('toggle_blocks') ):
$i = 1;
while( have_rows('toggle_blocks') ): the_row();
if( $atts['number'] == $i )
if( have_rows('toggles') ):
?>
<div class="toggles">
<?php
while ( have_rows('toggles') ) : the_row();
?>
<div class="toggle_container">
<div class="toggle_title">
<?php the_sub_field('toggle_title'); ?>
<i class="fas fa-chevron-right"></i>
</div>
<div class="toggle_content">
<?php the_sub_field('toggle_content'); ?>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif;
$i++;
endwhile;
endif;
endif;
return ob_get_clean();
add_shortcode('toggles-shortcode', 'do_toggles_shortcode');
And this is how the shortcodes look like:
[toggles-shortcode number="1"]
[toggles-shortcode number="2"]
I have a solution. This is the PHP code:
/** Create toggles Shortcodes */
function do_toggles_shortcode($atts)
$atts = shortcode_atts( array(
'number' => 1
), $atts );
ob_start();
if( function_exists('get_field') ):
if( have_rows('toggle_blocks') ):
$i = 1;
while( have_rows('toggle_blocks') ): the_row();
if( $atts['number'] == $i )
if( have_rows('toggles') ):
?>
<div class="toggles">
<?php
while ( have_rows('toggles') ) : the_row();
?>
<div class="toggle_container">
<div class="toggle_title">
<?php the_sub_field('toggle_title'); ?>
<i class="fas fa-chevron-right"></i>
</div>
<div class="toggle_content">
<?php the_sub_field('toggle_content'); ?>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif;
$i++;
endwhile;
endif;
endif;
return ob_get_clean();
add_shortcode('toggles-shortcode', 'do_toggles_shortcode');
And this is how the shortcodes look like:
[toggles-shortcode number="1"]
[toggles-shortcode number="2"]
answered Mar 22 at 0:11


BlueFishBlueFish
215
215
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290871%2fhow-can-i-add-multiple-shortcodes-inside-an-acf-repeater%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown