Skip Navigation

[Resolved] Creating custom fields with php / api?

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1223404

I’m embarking on a large multisite installation where each site is almost identical, except for the layouts of the page (let’s assume I’m using elementor to build the pages)

I want lots of custom fields through the site, however adding and updating fields later on across possibly hundreds of sites would be impossible to manage.

Normally I would use something like CMB2, where I can program all the fields in a functions file which populated through the multisite as they all use the same functions file.

I’d like to use toolset on this project, however I can’t seem to see if there’s a way of programmatically creating custom fields on a global scale without having to manually create them in each separate site of the network.

IS this possible? Even if it’s a custom function I would need to write and run a for each loop over each blog to update the tables and have it show inside the types admin?

#1223523

Hi, unfortunately there's no public API for programmatically creating Types custom fields. However, there are two other options that could make things a bit easier for you:
1. The Module Manager is designed to allow you to bundle custom fields, templates, views, custom taxonomies, and so forth. Compile those components into Modules, then install that same Module on multiple sites.
2. The Toolset import/export tool can be used to export an XML document of your Types settings. This will include the custom field groups, custom post types, custom taxonomies, and so forth. This file is editable, so in theory you could customize which of those elements you want to import in other sites.

If you'd like to see this type of API added to the software, I encourage you to submit a request here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
This will put your request in front of key decision makers who influence upcoming features.