• Resolved a4jp

    (@a4jpcom)


    What code can we add to the functions.php file to sort dynamic choices by categories and then by slugs not the actual names? I’m a designer trying to fix broken websites.

    I’ve set a field to
    Dynamic Choices > Taxonomy
    &
    Dynamic Taxonomy Source > Categories
    in the advanced section.

    I can’t see a Sort by URL/slug or Name setting. Your foreign language sort is broken without this setting.

    With a later update could you also add an auto generated category list where we can select multiple categories as a source in the advance settings please? That way we don’t have to filter and hide entries with CSS.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey @a4jpcom – Thanks for reaching out!

    Thanks for your suggestion on the feature that we can work on. Regarding your first question, I apologize as customizations like sorting by URL/slug are outside of our scope for support. In case you’d like to look into custom development options, we highly recommend using Codeable.

    About your second question, you can consider taking a look at our developer doc here.

    Thanks!

    Hey @a4jpcom – We haven’t heard back from you since my previous message, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

    Thread Starter a4jp

    (@a4jpcom)

    This isn’t resolved.

    Hey @a4jpcom – I looked into the message I posted initially and seems that I missed including the link to the related resources. I apologize for that, and you can take a look at our doc here and here. I hope this helps you to get started as beyond this it would fall outside the scope of support we can offer.

    Kindly,

    Hey @a4jpcom – I hope you got a chance to checkout the resources I shared. Please feel free to reachout if you have any questions about WPForms lite.

    Kindly,

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @a4jpcom,

    We haven’t heard back from you in about a few weeks, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hi @a4jpcom,

    I just thought I would chime in here and check if you still need help with this. I believe that you asked a similar question a month ago and we shared the following code which should be able to address the extra sorting that you need:

    /**
     * Add custom CSS classnames to dynamic choices.
     *
     * @param array $properties Properties for rendering the field on the frontend.
     * @param array $field      Original field data.
     * @param array $form_data  Form data.
     *
     * @return array
     */
    function wpforms_add_dynamic_choices_ids( $properties, $field, $form_data ) {
    
    	// Exit early if Dynamic Choices is not enabled.
    	if ( empty( $field['dynamic_choices'] ) ) {
    		return $properties;
    	}
    
    	// Get the prefix (post, page, category, post_tag, your_custom_post_type, your_custom_taxonomy).
    	$prefix = $field[ 'dynamic_' . $field['dynamic_choices'] ];
    
    	// Loop through all choices.
    	foreach ( $properties['inputs'] as $index => $input ) {
    		// Combine dynamic prefix with the real item (post, category etc) ID.
    		$class_name = $prefix . '-' . $input['attr']['value'];
    		// Add to list of choice item container classes.
    		$properties['inputs'][ $index ]['container']['class'][] = $class_name;
    	}
    
    	return $properties;
    }
    add_filter( 'wpforms_field_properties_checkbox', 'wpforms_add_dynamic_choices_ids', 10, 3 );
    add_filter( 'wpforms_field_properties_radio', 'wpforms_add_dynamic_choices_ids', 10, 3 );

    Please let us know if we are missing something.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sort Dynamic Checkboxes’ is closed to new replies.