• I’ve looked in the Codex and it appears that there are now functions to help add custom meta fields to taxonomy terms (add_term_meta). Unfortunately, I’m having trouble finding examples/tutorials that really seem to demonstrate adding checkbox or regular text input options. I found a tutorial on adding a color hex code to taxonomy terms, but it’s been a while since I’ve played around with WordPress functions and I’m having trouble parsing it for my use.

    I have two custom taxonomies. Let’s call them 'custom_tax_one' and 'custom_tax_two'. Both need to have the same three custom field checkboxes. Each checkbox will be connected to whether or not a specific icon displays next to the taxonomy term in the post templates. Only 'custom_tax_one' needs an additional text input field. This text input field will specifically be used to insert an optional link.

    The goal of associating the checkboxes and input fields with the taxonomies rather than the posts is to reduce replication of work.

    Any good existing tutorials for adding/using checkbox and/or text input options? Any pros out there willing to walk me through this or share some additional examples that might help me figure out what I need in order to develop a function for this?

    • This topic was modified 8 years, 4 months ago by bcworkz. Reason: moved to Hacks
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I do this with the plugin Advanced Custom Fields.

    Moderator bcworkz

    (@bcworkz)

    I moved your topic to the Hacks forum. It’s the best place for custom coding questions.

    The example color picker is actually closer than you think. There’s two main issues to address. One is obviously changing the color picker field to a checkbox or text field.

    The other is processing the submitted data when saving it. When the checkbox field is unchecked, there is no related data at all. It only appears when checked. For text fields, saving data is very much like saving colors, except the actual data is text instead of a hex code of course.

    You could actually use a lot of the code as is, except the use of “color” in variable names gets really confusing. Even though the chance of complications increases, I think it’s worth trying to rename everything to avoid confusion down the road.

    I can’t point you to any documentation, but I’m willing to help you work through this when you get stuck on something. This really isn’t any different than saving post meta except the edit page is different, you use add_term_meta() instead of add_post_meta(), and the action hooks have different names.

    Give it all a good effort and let’s see what you end up with.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add custom field checkboxes and text input options to a taxonomy’ is closed to new replies.