- This topic has 2 replies, 2 voices, and was last updated 8 years, 2 months ago by
Steve.
Viewing 2 reply threads
-
AuthorPosts
-
-
November 29, 2013 at 4:54 pm #1243
sanderschatMemberHi,
i think i still dont fully get this, hence my question:i have a user custom field created:
piklist('field', array('type' => 'select', 'field' => 'user_school', 'label' => 'School', 'choices' => piklist(get_terms('school', array('hide_empty' => FALSE)), array("term_id", "name"))));But instead of the ‘term_id’ i need to have a custom field of this given taxonomy ‘school’.
i think i need to use an sql-statement to get ‘name’ and the value of the custom field.
But how to get this result into the ‘choices’ field?thanks!
-
November 30, 2013 at 5:54 am #1244
sanderschatMemberA good night sleep will help…. 🙂
I thought to give it a try myself and yes, figured out the answer:global $wpdb; piklist('field', array('type' => 'select', 'field' => 'user_school', 'label' => 'School', 'choices' => piklist($wpdb->get_results("select t.name, tm.meta_value as 'legacy_id' from {$wpdb->prefix}term_taxonomy tt inner join {$wpdb->prefix}terms t on t.term_id = tt.term_id inner join {$wpdb->prefix}termmeta tm on tt.term_id = tm.term_id where tt.taxonomy='school' and tm.meta_key ='legacy_id'"), array("legacy_id", "name"))));thanks!
-
December 2, 2013 at 2:40 pm #1248
SteveKeymaster@sanderschat– Great job. Remember, Piklist does things the normal WordPress/PHP way. So getting the choices list would be the same if you were even generating a standard HTML form.
-
-
AuthorPosts
Viewing 2 reply threads
- You must be logged in to reply to this topic.