Skip Navigation

[Résolu] How to make a checkbox-list field of all posts with same post-meta?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created Il y a 10 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 réponses, has 2 voix.

Last updated by iann Il y a 10 années et 9 mois.

Assisted by: Luo Yang.

Auteur
Publications
#108545

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.

#109445

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

#110381

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

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.