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
- How can I show all users (selected role) as dropdown in custom meta box and
- 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 😉
WP_User_Query
objectMore info on
WP_User_Query
.For how to add metaboxes see the Codex entry and examples for this function.
Here is the code I used to create a dropdown of my Custom Post Type “Issues” to display the title of the “Issue” and have the value link to the single issue.
Hope it helps someone.