I know generally how to add custom fields to the user profile page. However, I need to add a custom select box to the profile page that is populated with all the schools in the state. (Our users will be teachers, and we need to be able to associate them with a school and a school system county.)

The school data is contained in a spreadsheet that includes the school name and county for every school in the state. Is there a way to somehow import this data into the select box?

All I can think to do is to create a Custom Post Type for "Schools" and import the school spreadsheet as posts. The school name would be the post title, and the other information would be custom fields for that post. Then I would need to pull all the post titles into the User Profile select box.

However it seems like overkill to have a CPT for this. Is there a better or easier way to import this data into a custom select box?

Another wrinkle is that this list will be updated every year, so we'll need to re-import the spreadsheet every year.

I appreciate any help to get me started. I'm thoroughly confused!

有帮助吗?

解决方案

You should import the schools as a table in the database, separate from the other WordPress tables. You can than write a function that selects and returns schools and eventually link it to the field via ajax using something like select2 or jquery autocomplete.

许可以下: CC-BY-SA归因
scroll top