• Hey everyone.

    I have a customer there wants a post Type which is a “module” (which basicly is a set of dates with information about place and so on)

    I was thinking that this might be able to be done using Custom meta fields, but the only problem I can see with this is that I can’t let i have for example 10 in one and then 5 in another.

    And i need it to be shown on a page (and being able to search through them also).

    I hope you have some points to what i can do and how it can be done (existing source would also be nice but not needed).

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    If you go one step beyond meta fields and use a custom meta box, then you can use arbitrary HTML and JavaScript to expand and contract the fields as needed, just as you could do on a normal HTML form. Store the data as an array, then it doesn’t matter how many elements are involved.

    https://developer.www.ads-software.com/plugins/metadata/creating-custom-meta-boxes/

    Thread Starter kasperfranz

    (@kasperfranz)

    I would add the custom fields to a custom meta box.

    with some code like this
    https://gist.github.com/KasperFranz/5b8c075616e0f2556028
    (just an example of how i could add a new meta box with custom fields)

    Would you make the meta box as an array instead and then post it? (and collect it with the callback?

    Moderator bcworkz

    (@bcworkz)

    Just allow the meta box form to post the fields as it normally would. The ‘save_post’ call back would then assemble the data from the $_POST array and perhaps organize as desired into a more logical array structure, which is then stored in post meta or where ever makes sense.

    There’s other ways, but this is straight forward and what I would do.

    Thread Starter kasperfranz

    (@kasperfranz)

    OMG Thank you so much.

    Sometimes you are just not looking at the hole picture and focusing to much on one solution.

    The worst part is that i was allready using the custom meta box with custom fields in it, I just forgot that the method i was using to generate the HTML field was a method i have made myself – so GG ^^

    Thank you for your help ??

    Moderator bcworkz

    (@bcworkz)

    Sure, any time ??

    Sometimes you are just not looking at the hole picture and focusing to much on one solution.

    Isn’t that the truth! Been there done that way too many times.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Best way to achieve a module with a set of dates.’ is closed to new replies.