I’m working for a WordPress Plugin. The plugins is for library management, for my university. I created custom post types with taxonomies for keeping books information stored. Now I want to create another post type which will keep records for books and and users. For instance, I’ll create new post type called “Issue”. There should have three fields. One would be title. Another two will be dropdown, one will show all book (I’ve already created custom post type called books, I want to use those here, automatically) lists as dropdown. Another dropdown field will show list of students (for this I’ve created a new user role called student, I want to use those user who are registered as student).

So my questions are

  1. How can I show all users (selected role) as dropdown in custom meta box and
  2. How can I show all books (Custom post type I created) as dropdown in custom meta box

How can these be done? I can code, need instruction 😉

2 Answers
2

  • To get the users who have the role called student, use the WP_User_Query object
  • For storing the fields, use post meta just as you would on normal posts, remember to declare that your custom post type supports custom fields when being registered
  • For your dropdown/etc you will need to register metaboxes

More info on WP_User_Query.

For how to add metaboxes see the Codex entry and examples for this function.

Leave a Reply

Your email address will not be published. Required fields are marked *