最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom field - Populate a select box with data stored in the database?

programmeradmin1浏览0评论

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!

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!

Share Improve this question asked Jan 26, 2015 at 17:35 LBFLBF 5393 gold badges11 silver badges28 bronze badges 1
  • School table autofill and custom fill – Munna Commented Nov 16, 2020 at 12:21
Add a comment  | 

1 Answer 1

Reset to default 0

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.

发布评论

评论列表(0)

  1. 暂无评论