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;








0















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.










share|improve this question




























    0















    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.










    share|improve this question
























      0












      0








      0








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 21 at 23:48









      BlueFishBlueFish

      215




      215






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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"]






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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"]






            share|improve this answer



























              0














              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"]






              share|improve this answer

























                0












                0








                0







                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"]






                share|improve this answer













                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"]







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 22 at 0:11









                BlueFishBlueFish

                215




                215





























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript