Tagged: repeater
- This topic has 6 replies, 2 voices, and was last updated 7 years, 1 month ago by
dawood.
-
AuthorPosts
-
-
December 12, 2014 at 1:42 pm #3069
dawoodMemberHow would I go about creating a repeater field that allows the user to link to a pages?
I’ve tried a text area that the user can just type the links but seems a page link repeater feild would be more user friendly?
-
December 12, 2014 at 3:25 pm #3071
SteveKeymaster@dawood– Would a text box, repeater, work? All you need to do is create a standard text field and add:
'add_more' => truepiklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Example Field' ,'description' => 'This is a description of the field.' ,'columns' => 12 ,'add_more' => true )); -
December 13, 2014 at 11:31 am #3074
dawoodMemberI that could work, is there anyway to pull in just the link field for the TINY MCE editor so the user can link to any page in their wp site?
-
December 14, 2014 at 7:25 pm #3084
-
December 14, 2014 at 11:51 pm #3093
dawoodMemberYeah, that would work, I could just do a standard editor in that case… 🙂
I normally use Advanced Custom Fields plugin and there’s an option to add a “Page Link” field, and use that fairly often, so was trying to see how I could replicate that …
-
December 15, 2014 at 11:00 am #3101
SteveKeymaster@dawood– The code you posted here looks just like the “Page Link” field.
piklist('field', array( 'type' => 'select' ,'field' => 'dawood' ,'columns' => 12 ,'attributes' => array( 'multiple' => 'multiple' ) ,'choices' => piklist( get_posts( array( 'post_type' => 'post' ,'orderby' => 'post_date' ) ,'objects' ) ,array( 'ID' ,'post_title' ) ) ));Since you are setting this field to allow for multiple values selected, you need to loop over the array:
foreach ($dawood as $key => $value) { echo '' . get_the_title($value) . ''; }The biggest difference here between ACF and Piklist, is that Piklist allows you to use standard WordPress functions like
get_permalink()andget_the_title(), while ACF makes you use it’s own functions. -
December 17, 2014 at 10:54 am #3107
dawoodMemberThanks Steve that helps!
-
-
AuthorPosts
- The topic ‘Repeater Link Field’ is closed to new replies.