- This topic has 3 replies, 2 voices, and was last updated 7 years, 1 month ago by
Steve.
-
AuthorPosts
-
-
December 11, 2014 at 3:05 pm #3062
azizultexMemberHowdy,
I am trying to get the value ofAdd Morefrom setting page. I am able to get result from Basic Add More using below code:$settings = get_option('my_theme_settings'); $exercises = $settings['exercise']; echo '<ul>'; foreach ($exercises as $exercise) { echo "<li> $exercise </li>"; } echo '</ul>';for the Advanced Add More, I am trying to get the result using something like this:
$settings = get_option('my_theme_settings'); $workout_schedules = $settings['workout_schedule']; echo '<ul>'; foreach ( $workout_schedules as $schedule ) { $days = $schedule['day']; foreach ($days as $day ) { echo "Day: $day <br/>"; } $exercise_days = $schedule['exercise_day']; foreach ($exercise_days as $exercise_day ) { $exercise_reps = $exercise_day['exercise_reps']; $exercise_sets = $exercise_day['exercise_sets']; $exercise_name = $exercise_day['exercise']; echo "Exercise: $exercise_name, Recipe: $exercise_reps , Sets: $exercise_sets "; } } echo '</ul>';But this not working. How can I show the result?
Thanks
-
December 11, 2014 at 5:40 pm #3063
SteveKeymasterAdvanced Add-mores are multi-layered. Please read the docs and let us know if it helps.
-
December 25, 2014 at 3:42 pm #3131
azizultexMemberHi,
I am sorry for the delay to reply you. I tried today, but couldn’t get it worked.I used below code in my metabox that is showing field in post types.
<?php /* Title: My Metabox Description: My cool new metabox Post Type: post */ // Let's create a text box field piklist('field', array( 'type' => 'text' ,'field' => 'exercise' ,'add_more' => true ,'label' => __('Workout') )); ?>I used below code in my single.php file after the_content()
<?php // Get field data $exercise = get_post_meta($post->ID, 'exercise', true); // Get your custom template part: addmore-workout-template.php piklist(get_stylesheet_directory() . '/piklist/add-more-templates/addmore-workout-template', array('data' => $exercise, 'loop' => 'data')); ?>and
addmore-workout-template.phpfile looks like this:<?php echo $data['exercise']; ?>Finally, I receive this error: http://s21.postimg.org/w3o9q8b4n/screenshot_163.png
Where am I doing wrong?
-
December 29, 2014 at 12:55 pm #3140
SteveKeymaster@azizultex– This is really a different post. Your first one was ADVANCED Add-more’s… this is clearly a SIMPLE Add-More. In the future please create a new ticket.
All you need to do here is:
$exercises = get_post_meta($post->ID, 'exercise'); foreach ($exercises as $exercise => $value) { echo $value; }
-
-
AuthorPosts
- You must be logged in to reply to this topic.