{"id":1483,"date":"2017-03-04T12:11:53","date_gmt":"2017-03-04T11:11:53","guid":{"rendered":"https:\/\/www.nieuwsmarkt.nl\/?p=1483"},"modified":"2017-10-01T09:09:55","modified_gmt":"2017-10-01T07:09:55","slug":"working-with-repeating-fields-in-beaver-themer","status":"publish","type":"post","link":"https:\/\/www.nieuwsmarkt.nl\/nl\/blog\/2017\/03\/04\/working-with-repeating-fields-in-beaver-themer\/","title":{"rendered":"Working with repeating fields in Beaver Themer"},"content":{"rendered":"<p><strong>Repeating fields are part of the\u00a0Advanced Custom Fields Pro package but represent a very powerful fieldtype, used a lot in lists of repeating products or services. Beaver Themer doe not have yet native support for the ACF Pro fieldtypes, so a little workaround might help for the time being.<\/strong><!--more--><\/p>\n<p>For our project <a href=\"https:\/\/fitnesskeuze.nl\" target=\"_blank\">fitnesskeuze.nl<\/a> we were looking for a way on how to display two repeating fields, defined in the field\u00a0group &#8216;sportscholen&#8217;. The two fields represent &#8216;groepslessen&#8217; (group lessons) and &#8216;faciliteiten&#8217; (facilities). Both\u00a0fields have the freedom to add &#8216;subrecords&#8217; depending on the amount of lessons and facilities each\u00a0sportschool\/fitness centre might have.<\/p>\n<div id=\"attachment_1486\" style=\"width: 1034px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/grouplessons.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1486\" class=\"wp-image-1486 size-large\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/grouplessons-1024x569.jpg\" width=\"1024\" height=\"569\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/grouplessons-1024x569.jpg 1024w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/grouplessons-300x167.jpg 300w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/grouplessons-768x427.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><p id=\"caption-attachment-1486\" class=\"wp-caption-text\">Creation of the repeating field &#8216;groepslessen&#8217; with the two subfields &#8216;naam&#8217; en &#8216;omschrijving&#8217; in the ACF Pro back-end<\/p><\/div>\n<p>In both\u00a0repeating fields we added just two subfields. &#8216;Naam&#8217; stands for the name of the grouplessons and &#8216;omschrijving&#8217; is the description of that lesson. So far so good in the back-end of our solution. Adding a CPT record &#8216;sportschool&#8217; was initially done via the back-end as well, but the customer requested that a form could be used in the front-end for easy input (without user registration for the testperiod). The CPT record would have to appear as a draft for later approval and publication.<\/p>\n<h3>The solution<\/h3>\n<p>First we installed the brand new plugin <a href=\"https:\/\/wordpress.org\/plugins\/advanced-forms\/\" target=\"_blank\">Advanced Forms<\/a>, a plugin for creating ACF forms in the front-end of your solution. Advanced Forms does support the\u00a0ACF Pro repeating field, so that fitted our needs. The plugin creates its own (temporary) CPT record after each submit. We asked the developer to create a possibility to &#8216;convert&#8217; this temporary CPT record to any CPT already created (in our case &#8216;sportscholen&#8217;). Developer <a href=\"https:\/\/profiles.wordpress.org\/fabianlindfors\/\" target=\"_blank\">Fabian Lindfors<\/a> would have a look, but until now we will work with just a simple &#8216;post type converter&#8217; called <a href=\"https:\/\/wordpress.org\/plugins\/post-type-switcher\/\" target=\"_blank\">Post Type Switcher<\/a>. \u00a0We could have made a simple routine to do this, but for the test phase of our project, this solution worked fine.<\/p>\n<div id=\"attachment_1488\" style=\"width: 1034px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/front-end-form.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1488\" class=\"wp-image-1488 size-large\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/front-end-form-1024x398.jpg\" width=\"1024\" height=\"398\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/front-end-form-1024x398.jpg 1024w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/front-end-form-300x117.jpg 300w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/front-end-form-768x298.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><p id=\"caption-attachment-1488\" class=\"wp-caption-text\">Using Advanced Forms in the front-end<\/p><\/div>\n<h3>Beaver Themer and Custom Content Shortcode<\/h3>\n<div id=\"attachment_1490\" style=\"width: 924px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1490\" class=\"wp-image-1490 size-large\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field-914x1024.jpg\" width=\"914\" height=\"1024\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field-914x1024.jpg 914w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field-268x300.jpg 268w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field-768x861.jpg 768w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/repeater-field.jpg 1458w\" sizes=\"auto, (max-width: 914px) 100vw, 914px\" \/><\/a><p id=\"caption-attachment-1490\" class=\"wp-caption-text\">A list of Custom Content Code possibilities, here an example of using ACF Pro repeating fields<\/p><\/div>\n<p>We do already use (with the customers permission) Beaver Themer to display both the archive page and the single page for the created CPT records. With the plug-in <a href=\"https:\/\/wordpress.org\/plugins\/custom-content-shortcode\/\" target=\"_blank\">Custom Content Shortcode<\/a>\u00a0we ware able to display the two repeating fields. We hope that repeating field will become natively supported within Beaver Themer. The used plug-in works fine under WordPress 4.7.2, but no updates have been supplied in the last 9 months. The plugin does have some &#8216;special&#8217; settings for ACF support and that worked fine for our setup.<\/p>\n<div id=\"attachment_1492\" style=\"width: 410px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1492\" class=\"wp-image-1492\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields-1024x964.jpg\" width=\"400\" height=\"377\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields-1024x964.jpg 1024w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields-300x282.jpg 300w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields-768x723.jpg 768w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/03\/using-rep-fields.jpg 1222w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><p id=\"caption-attachment-1492\" class=\"wp-caption-text\">Using the code in Beaver Themer<\/p><\/div>\n<p>We did just use the basic setup for displaying the two repeating fields, but with the plug-in any conditional could be created (nicely done). We did not test\u00a0this in combination with the <a href=\"http:\/\/kb.wpbeaverbuilder.com\/article\/390-theme-builder-field-connection-shortcodes\" target=\"_blank\">conditional possibilities<\/a> offered with Beaver Themer yet.<\/p>\n<p>Although not yet in it&#8217;s final (creative) layout, an <a href=\"https:\/\/fitnesskeuze.nl\/sportscholen\/sportcity-amsterdam-wibautstraat\/\" target=\"_blank\">example<\/a> of the output just shows the easy integration in the single post layout created by Beaver Themer.<\/p>\n<h3>The next steps &#8211; suggestions welcome<\/h3>\n<p>This works for now, but we do seriously hope that Beaver Themer will add\u00a0support for repeating fields soon, and that it will integrate within the Beaver Themer conditionals. We will replace the Post Type Switcher by a small routine in functions.php in the childtheme, if the developer of the Advanced Forms plug-in will not integrate this in his next version.<\/p>\n<p>While people might fill in the front-end form, in the end we would like to give them the possibility to edit their content. Therefore a new user should be registered at the moment they create the CPT record. If that could be done, we would like to add an edit screen of the form in which the specific user can edit only his\/her own CPT record. Any suggestion would be very welcome.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Repeating fields are part of the Advanced Custom Fields Pro package but represent a very powerful fieldtype, used a lot in lists of repeating products or services. Beaver Themer doe not have yet native support for the ACF Pro fieldtypes, so a little workaround might help for the time being.<\/p>","protected":false},"author":2,"featured_media":1509,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[64],"class_list":["post-1483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","category-test","tag-repeating-fields"],"_links":{"self":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/1483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/comments?post=1483"}],"version-history":[{"count":4,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/1483\/revisions"}],"predecessor-version":[{"id":1574,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/1483\/revisions\/1574"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media\/1509"}],"wp:attachment":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media?parent=1483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/categories?post=1483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/tags?post=1483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}