Forums

Query_posts multiple dynamic checkboxes from custom post (2 posts)

  1. MrMastermindNL
    Member
    Posted 6 months ago #

    Hi,

    I have created a custom field that can have multiple checkboxes for products that are related to that post, that can be added dynamically using Javascript. At first I just saved the serialized array of checked checkboxes, but I also have to be able to query based on the checkboxes. I need to be able to do a query that returns all posts that have a specific checkbox checked.
    So eventually I need to save the checkboxes separately in a meta_key for each checkbox.
    So far I can manage, but how would I query the checkboxes without knowing exactly how many different meta_keys there are for the checkboxes?
    I guess when saving the checkboxes they will be named something like: post_product_1, post_product_2, etc..

    I hope the question makes sense.

  2. MrMastermindNL
    Member
    Posted 6 months ago #

    Thinking about this, would it be useful to have a custom taxonomy "products" which both the product-post-type and the other post-type need to use? So I can query on the taxonomy? Or will that give complications?

Reply

You must log in to post.

About this Topic