- This topic has 2 replies, 2 voices, and was last updated 6 years, 2 months ago by
sancreative.
-
AuthorPosts
-
-
November 24, 2015 at 6:44 pm #5098
sancreativeMemberHi There,
Im just trying to follow some of your demo’s to get a feel of piklist before adding it to some projects I’m working on.
I followed along with the repeater field demo in the doc’s and keep getting an error while trying to display the fields on frontend.
I’ve kept it simple with the beasic example.
code in metaboxes file assigned to pages
<?php piklist('field', array( 'type' => 'text' ,'field' => 'exercise' ,'add_more' => true ,'label' => __('Workout') )); ?>code in page.php
<?php // Get field data $exercise = get_post_meta($post->ID, 'exercise', true); // Get your custom template part: addmore-workout-template.php piklist(piklist::$paths['distincthq-builder'] . '/addmore-workout-template', array('data' => $exercise, 'loop' => 'data')); ?>and finally code in addmore-workout-template.php (placed in the plugin dir)
<div class="test"><?php echo $data['exercise']; ?></div>the result:
Warning: Illegal string offset ‘exercise’ in /home/dh2serve/public_html/dev/wp-content/plugins/distincthq-builder/addmore-workout-template.php on line 1
Mscreenshots of my page custom fields attached
Attachments:
You must be logged in to view attached files. -
November 25, 2015 at 11:19 am #5101
SteveKeymaster@sancreative– I suggest you use the latest beta, v0.9.9.x.
Once you upgrade, you will not longer need to use this code:
piklist(piklist::$paths['distincthq-builder'] . '/addmore-workout-template', array('data' => $exercise, 'loop' => 'data'));You will be able to just loop through the data like this:
$exercises = get_post_meta($post->ID, 'exercise', false); foreach ($exercises as $exercise => $value) { echo "<div class='test'>" . $value . "</div>"; } -
November 25, 2015 at 12:39 pm #5102
sancreativeMemberthanks for the code example, works perfect.
I was using the latest beta version Piklist v0.9.9.6
-
-
AuthorPosts
- The topic ‘Repeater Field’ is closed to new replies.