- This topic has 5 replies, 3 voices, and was last updated 5 years, 4 months ago by
mcmaster.
-
AuthorPosts
-
-
November 22, 2015 at 9:23 pm #5058
mcmasterMemberDo Piklist shortcodes support fields that are groups or add-mores? I tried to build a shortcode with an add-more group, but it failed to store the field values. Changed it to just a group (no add-more) but it still failed. Worked when I used individual fields.
If these are supposed to work, then let me know and I’ll follow up with more details.
Second, the ungrouped version of my shortcode has four fields: 2 text, image upload, and editor (teeny). For some reason the editor field (‘content’) was not displaying. However, it was being saved in the database and showed up when I went back to edit the shortcode.
I tried a few things, and then on a hunch changed the name of the field to ‘descr.’ Shazaam, it works! Changed it back to ‘content’ and it fails again. I use ‘content’ pretty often as a field name inside a group (e.g., title, image, content). Is it considered a reserved word when used as a field name?
Here’s the form code file before changing it to ‘descr’:
/* Name: Feature Page Description: Add a featured page Shortcode: mcw-feature Icon: dashicons-migrate */ piklist( 'field', array( 'type' => 'text', 'field' => 'title', 'label' => 'Title', 'columns' => 8, )); piklist( 'field', array( 'type' => 'file', 'field' => 'image', 'label' => 'Image', 'description' => 'Add or upload an image.', 'options' => array( 'modal_title' => 'Add Image', 'button' => 'Add Image', ) )); piklist( 'field', array( 'type' => 'editor', 'field' => 'content', 'label' => 'Description', 'columns' => 12, 'options' => array ( 'media_buttons' => false, 'teeny' => true, ) )); piklist( 'field', array( 'type' => 'text', 'field' => 'link', 'label' => 'Link to Page', 'description' => "If typing in a web address (URL), don't forget the 'http://'.", 'columns' => 12, ));and the display code file:
/* Shortcode: mcw-feature */ $linked_title = mcw_get_anchor( $link, wptexturize( $title ) ); $thumb = wp_get_attachment_image( $image, 'portal-thumb', false, 'class=img-responsive' ); $linked_image = mcw_get_anchor( $link, $thumb ); $content = apply_filters( 'the_content', $content ); ?> <div class="portal"> <div class="col-sm-7"> <h2><?php echo $linked_title; ?></h2> <?php echo $content; ?> </div> <div class="col-sm-5"> <?php echo $linked_image; ?> </div><!-- col-sm-5 --> </div> -
November 22, 2015 at 9:28 pm #5059
mcmasterMemberFYI the content is being saved in the post_content field as:
[mcw-feature title="Test" image="451" content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Etiam porta sem malesuada magna mollis euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit." link="/foo/" _index="0"] -
November 29, 2015 at 11:59 am #5155
MarcMemberThat’s a great question!
I just tried to do the same today.
It would be an amazing feature, for exemple to make sliders or other repeatable content.
I’m working on a system to make easy content updates for complicated templates, and this would probably be one of the easiest way.
So I would be very interested to hear about this! -
November 29, 2015 at 8:21 pm #5159
mcmasterMemberYes, I think it would be ideal for creating what ACF refers to as Flexible Content. (Actually, @kevin is the one who gave me that idea a while back.) See also this discussion on wpchat: https://wpchat.com/t/pros-cons-of-piklist-vs-acf/1196/6
-
September 14, 2016 at 12:36 pm #7338
kutyadogParticipantWas this issue ever solved?
I am trying the same thing and am looking for a solution.
Thanks
Chris -
September 14, 2016 at 5:09 pm #7339
mcmasterMember@kutyadog, it depends on exactly what you are trying to do. The problem with grouped fields in shortcodes has not been fixed. I think they may be trying a different approach to the problem.
I was able to simulate flexible content by creating a shortcode for each type of content panel. For the simpler ones, e.g., a blockquote or a box with image and text, the content is edited directly into the shortcode. For panels that require add-mores, I have a separate metabox for creating an add-more and the shortcode just references it.
It’s a kluge but it works and my client is comfortable with it. If you would like more details, let me know and I’ll answer as well as I can.
Donna
-
-
AuthorPosts
- You must be logged in to reply to this topic.