My site uses a post type for educational "Course Materials".
When contributors create a new post in this type, I want them to be able to check from a list of existing posts that may be related to the post they are creating.
For example, if a contributor is creating a new post in "Mathematics", I want them to have, in the admin, an available checkbox list "Related course materials" whose options would be a query of all EXISTING posts that have the category "Mathematics".
In my example, since not all "Mathematics" posts will be related to the post being created, I want the contributor to have the option of checking from this list which should be stored as "Related course materials" postmeta. I would want to store the post-ID of these posts as the postmeta.
In broader terms, my question is how to generate dynamically-populated field options for a checkbox list within a field group, from the post database.
Other checkbox lists might be generated in the same way - posts with the same "grade level" postmeta, posts with the same "Teacher type" postmeta, etc...
This relates to backend only, not front-end display of the post meta.
I haven't found an existing answer in the forums.
Hi iann,
It is not possible within Types, and you can try create a PHP function using WP action hooks: save_post
http://codex.wordpress.org/Plugin_API/Action_Reference/save_post
save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited. For example, quick edits use $_GET.
Hope it help
Hi Luoy,
I did end up doing something like this. Thanks
For anyone else who finds this thread, a more detailed code example was here:
http://wordpress.stackexchange.com/questions/71043/listing-pages-with-checkboxes-in-a-metabox-and-saving-them