Viewing 6 reply threads
  • Author
    Posts
    • #8756
      Ico
      Member

      Hi,
      I understand why add_more is not working in shortcodes ( the add_more is displayed in shortcode form, but the inserted shortcode takes only the last item ). It is probably a lot of work to implement and probably is not a popular request, but did someone found a workaround?

    • #8760
      Steve
      Keymaster

      I don’t understand. ‘add_more’ is a field parameter. Any fields generated by a shortcode will work.

    • #8762
      Ico
      Member

      Hi, I’m not native english speaker, so my bad. What I want to create a shortcode and a form. Here is the code:

      test-form.php

      <?php
      /*
      Name: Post Shortcode
      Description: Adding add_more field to shortcoe
      Shortcode: test
      Inline: false
      */
      
      piklist('field', array(
          'type' => 'text',
          'field' => 'test_text',
          'label' => 'Text',
          'add_more' => true
        ));

      test.php

      <?php
      /*
      Shortcode: test
      */
      ?>
      <div style="color:grey;">
      <span> Args :</span>
      <pre><?php print_r( $arguments); ?></pre>
      </div>

      When I open the modal to insert the shortcode, I have repeating field in the form. If I create three fields ( 1, 2, 3 ), when I insert the shortcode into the editor, only the last shortcode value is added ( the result is ):

      [test test_text="3" _index="0"]

      I added some screenshots : https://my.pcloud.com/publink/show?code=kZn0SL7ZYQw0TpwsSMuL4Pi5rie6sLoCfPNV

      Is there a way to make it work? It would be very helpful!

      Best,
      Chris

      Attachments:
      You must be logged in to view attached files.
    • #8774
      Ico
      Member

      Up ⬆️

    • #8785
      Steve
      Keymaster

      @bassta– You just stumbled upon a powerful and undocumented feature of Piklist. The ability to save shortcode data to your database. Undocumented… until now. Try this tutorial and let me know what you think >

    • #8789
      Ico
      Member

      Thanks Steve, it is working for a single field. So the idea is I can pass single values just as shortcode vars and one’s with repeater using save_id, scope and hidden field, then retrieve them with get_post_meta($post->ID, 'my_shortcode_saved_to_db', false); .

      This is just great, thanks a lot!

    • #8791
      Ico
      Member

      Update:

      The data is displayed just fine, but clicking when trying to edit the shortcode (click on edit and modal pops-up ) only the first value is displayed;

Viewing 6 reply threads
  • You must be logged in to reply to this topic.