Viewing 1 reply thread
  • Author
    Posts
    • #8272
      brianeoneill
      Participant

      Hi. Just discovered Piklist, and I’m using it to create a theme for podcasters. I’m creating a custom meta box where users can enter details about the music that’s included in an episode.

      For each song, the user should be able to add the title, artist, and a URL. This should be a repeater, so the user can add as many songs as needed.

      I’m trying this, but it’s not working:

      piklist('field', array(
      	
      	'label' => 'Music',
      	'description' => 'Add songs from this episode',
      	'add_more' => true,
      
      	'fields' => array(
      		array(
      			'type' => 'text',
      			'value' => 'song title',
      			'field' => 'song_title'
      		),
      		array(
      			'type' => 'text',
      			'value' => 'song artist',
      			'field' => 'song_artist'
      		),
      		array(
      			'type' => 'text',
      			'value' => 'song url',
      			'field' => 'song_url'
      		)
      	)
      
      ));

      Am I doing something wrong?

    • #8279
      mcmaster
      Member

      Hi, @ brianeoneill, you’re on the right track but you’re missing a few pieces.

      Your container field needs a type. You may also want to add labels for your sub-fields:

      
      piklist('field', array(
      	'type' => 'group', // <== needed 
      	'field' => 'music', // <== optional
      	'label' => 'Music',
      	'description' => 'Add songs from this episode',
      	'add_more' => true,
      
      	'fields' => array(
      		array(
      			'type' => 'text',
      			'value' => 'song title',
      			'field' => 'song_title'
      			'label' => 'Title', // <== optional
      		),
      		array(
      			'type' => 'text',
      			'value' => 'song artist',
      			'field' => 'song_artist'
      			'label' => 'Artist', // <== optional
      		),
      		array(
      			'type' => 'text',
      			'value' => 'song url',
      			'field' => 'song_url'
      			'label' => 'URL', // <== optional
      		)
      	)
      
      ));
      

      See the example here for more details.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.