Tagged: addmore, addmore not working, addmore usage, get data from addmore field, image addmore addmore fields, styling addmore
- This topic has 2 replies, 2 voices, and was last updated 5 years, 8 months ago by
semwangajoshua.
-
AuthorPosts
-
-
May 18, 2016 at 4:32 am #6507
semwangajoshuaMemberHullo there everybody, This is a long post but I kindly and politely ask that you bear with me. I’m working on an image addmore field but I’m failing to make it work. I’ve followed and used the sample code in the Piklist documentation and changed the fetched field name as required and the template part file path as neccessary but nothing seems to work. I also honestly think that most times it’s a good thing to indicate explicitly in the documentation where you expect the user to place the sample documentation provided other than assuming that everybody knows exactly where the code has to go. Many times things fail to workout simply because the right thing is being implemented wrongly; and then that adds on to the load of questions that have to come here on the forum. How I wish Piklist would work around this weakness. Personally, for my current challenge with the addmore I’m working on, I’ve had a tough time figuring out where the sample code provided in the Piklist documentation goes. I’ve read the WordPress Codex referenced to get insights but unfortunately the Codex as well assumes that everyone knows where to put the code; So it’s been of a little help. I’ve swapped the code several times between my template file and the template part trying to make it workout but still without any success. My workflow is like this; I have a template page called page-home.php which lays out the homepage on the frontend and as well makes usage of all my piklist field values by requiring variables.php. Then I have another file called variables.php where I make all my variable definitions and data calls so as to use them in page-home.php. I created a template part file called addmore-home.php as advised in the documentation. I wonder what code goes into the created template part i.e., addmore.php and which code goes into the page template file i.e., page-home.php that lays out the actual page? The closest I’ve come to making it work, the frontend page source shows this error:
<b>Warning</b>: Illegal string offset 'clientele_logo' in <b>C:\xampp\htdocs\lawyeah\wp-content\themes\JointsWP-CSS-master\parts\addmore-home.php</b> on line <b>2</b><br />
It’s complaining about this line in of code in the addmore-home.php file:
<?php echo $data['clientele_logo'];?>And I have this code in my page-home.php file:
<?php // Get field data $clientele_logo = get_post_meta($post->ID, 'clientele_logo', true); // Get your custom template part: addmore-workout-template.php piklist(get_stylesheet_directory() . 'parts/addmore-home', array('data' => $clientele_logo, 'loop' => 'data')); ?>If you take notice, you understand that one can add multiple files especially images from the WordPress uploader all at once. This then means that the addmore created will have child elements of images within it and not just one image. This kind of working is a really big time-saver in a scenario where the user is expected to add many images to the section e.g., a gallery because if they have all these images prepared in one location, they can upload all of them at once and attach them at once instead just clicking on each individual image; which is time wasting and tiring. I’d love to take advantage of this ability so that my ddmore field is very effective. And by the way, it also saves you working space in the backend since the added images are tiled in a single addmore field instead of adding more addmore field rows down and with just a single image each. May someone help me figure out how I do this with Piklist’s addmore field? Please refer to the attached image for more insight into what I’m saying.
Attachments:
You must be logged in to view attached files. -
May 19, 2016 at 10:26 pm #6515
SteveKeymaster@semwangajoshua– I think you have two different issues, correct?
1) If you upgrade to the latest beta, the repeater field data is stored as an easy to use array. You can just loop over $clientele_logo in your template file. Much easier than using the old Piklist template part.
2) The screen shots are showing two different types of fields. A nested repeater and a repeater.
-
May 20, 2016 at 7:07 am #6521
semwangajoshuaMemberAlright Steve. Let me use that advice and see how things work out. Thank you for your time and support over here. I very much appreciate it.
-
-
AuthorPosts
- You must be logged in to reply to this topic.