Tagged: get_terms, piklist function
- This topic has 7 replies, 3 voices, and was last updated 9 years, 6 months ago by
Steve.
-
AuthorPosts
-
-
July 24, 2012 at 11:02 am #117
ehoansheltMemberHey guys,
So I got the basics down now where I can display a list of post_metas along the side of the post editor. This is a replica of what the tags and categories looks like.
What I’m trying to do now is to be able to make that more dynamic rather then static php.
This is what I would like to do and hopefully you can guide me to the right path. I created a custom post type “Providers” and I would like to have a taxonomy of “Specialty” where we can add more specialties as they come in via the admin menu Providers > Specialties. I got the taxonomy menu to show up using this code:
I also have the specialty values pulling into the post editor using this code:
Now I understand that I would need to plug in the values in the taxonomy page but how would I pull in those taxonomies using piklist?
Thanks for the support!
-
July 24, 2012 at 4:21 pm #120
KevinKeymasterOf course 🙂
‘choices’ => piklist(get_terms(‘specialty’), array(‘slug’, ‘name’))
The piklist function works like wp_list_pluck when you pass an object or array as the first parameter and an array containing the key or key/value pair you want to pluck as the second parameter.
Let us know if you need anything else.
Thanks,
Kevin
-
July 24, 2012 at 4:59 pm #121
ehoansheltMemberHey Kevin,
That looks great 🙂
Is their anywhere in the documentation that mentions this?
I tried the code above and when I added a taxonomy, it doesnt show up in the specialty sidebar.
This is the current side bar code. Sorry to ask so many questions!
-
July 24, 2012 at 8:55 pm #123
SteveKeymaster@ehoanshelt– This is a little confusing and definitely needs a tutorial… which we will write up this week.
You can try this code, which I reformatted a bit to make it easier to explain:http://pastebin.com/RCaFUdcP
Essentially you can use any of the parameters in the WordPress get_terms function. The reason nothing was showing up was probably because no posts (or CPT’s) were actually assigned as a “specialty”. By default get_terms only shows taxonomies that have content assigned to it.
By setting “hide_empty” => 0, you told WordPress to pull all the taxonomy values for “specialty”, regardless if they have content assigned or not.
Try out that code and let us know if it works.
-
July 24, 2012 at 9:18 pm #125
ehoansheltMemberYou guys have been great thus far and that worked for me like a charm. This is a really neat system once you know the ins and outs.
The finally thing I’m running into and this project is done on my side is these errors:
Warning: Illegal offset type in isset or empty in /Applications/MAMP/htdocs/woocommerce/wp-includes/taxonomy.php on line 223
Warning: Illegal offset type in isset or empty in /Applications/MAMP/htdocs/woocommerce/wp-includes/taxonomy.php on line 223
Warning: Cannot modify header information – headers already sent by (output started at /Applications/MAMP/htdocs/woocommerce/wp-includes/taxonomy.php:223) in /Applications/MAMP/htdocs/woocommerce/wp-includes/pluggable.php on line 881
Have you seen these before?
I disabled all plugins but piklist. I can move this question to a new thread if that would be better!
Thanks for the support guys. I really appreciate it!
-
July 24, 2012 at 9:33 pm #126
SteveKeymasterThese look like PHP notices, which we are working on. Check out this thread and see if they go away: http://piklist.com/support/topic/new-install-w-errors/
-
July 24, 2012 at 9:34 pm #127
ehoansheltMemberThanks Steve,
That is what I did for now and it works good enough for me 🙂
Thanks for the great support!
-
July 27, 2012 at 7:12 pm #142
SteveKeymasterAll PHP notices should be gone in v0.5.6
-
-
AuthorPosts
- You must be logged in to reply to this topic.