Maximum amount for multiple select for the "taxonomy advanced"-field

Support General Maximum amount for multiple select for the "taxonomy advanced"-field

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30623
    Andreas WunderseeAndreas Wundersee
    Participant

    I use the "taxonomy advanced"-field in a frontend form to select topics for blog entries. People could select multiple categories - so far everything works well - but I need a maximum amount for the selection. I couldn't find the possibility in the documentation for the "taxonomy advanced"-field. Is it possible to limit the number to three?

    Thanks for your support,
    Andi

    #30636
    Long NguyenLong Nguyen
    Moderator

    Hi Andreas,

    You can allow the user to select one category per input box. Then enable the cloneable setting and set the max_clone setting to 3. Here is the sample code:

    [
        'name'           => __( 'Taxonomy', 'your-text-domain' ),
        'id'             => $prefix . 'taxonomy_rbgrdv9a23p',
        'type'           => 'taxonomy_advanced',
        'taxonomy'       => ['category'],
        'field_type'     => 'select_advanced',
        'clone'          => true,
        'max_clone'      => 3,
    ],

    Read more on this documentation https://docs.metabox.io/cloning-fields/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.