Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #3080
      dawood
      Member

      Not sure what I am doing wrong,

      I have this field showing on homepage

      <?php
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'exercise'
          ,'add_more' => true
          ,'label' => __('Workout')
        ));
       
      ?>

      Then looping

      <?php 
      	if (have_posts()) :
         while (have_posts()) :
            	the_post();
              the_content();
              get_post_meta($post->ID, 'exercise', true);
      		piklist(get_stylesheet_directory() . '/workout_schedule_template', array('data' => $exercise, 'loop' => 'data'));
       
         endwhile;
      endif;
       ?>

      template

      <code><?php echo $data['$exercise']; ?></code>
      
    • #3081
      dawood
      Member

      Forgot to add

      $exercise= get_post_meta($post->ID, ‘exercise’, true);
      vs get_post_meta($post->ID, ‘exercise’, true);

      Can I close the topics myself?

      and why would this

      <?php echo $data['exercise']; ?>
      

      not work,
      but

      <?php echo $data ?>
      

      does?

    • #3088
      Steve
      Keymaster

      @dawood– The $data array is only made up of one key, exercise, that’s why $data works.

    • #3091
      dawood
      Member

      thanks for taking the time Steve,

      so the $data[‘exercise’]; would be in case there were multiple levels in the array?

    • #3095
      Steve
      Keymaster

      @dawood– Take a look at the array example given in this doc, that should help explain.

      Use can always use print_r() to view the array: print_r($data);

    • #3096
      dawood
      Member

      Thanks Steve,

      we can close this 🙂

Viewing 5 reply threads
  • The topic ‘Can't Get Add More Fields to Show’ is closed to new replies.