Title: Sortable Function isn&#8217;t working for Groups
Last modified: November 2, 2016

---

# Sortable Function isn’t working for Groups

 *  Resolved [ajuliano](https://wordpress.org/support/users/ajuliano/)
 * (@ajuliano)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/sortable-function-isnt-working-for-groups/)
 * Hi,
 * This a really great plugin that helps us a lot in our work!
 * But we have a problem where the Sortable Function for groups isn’t working. Even
   after saving the Page as noted as a solution here: [https://github.com/WebDevStudios/CMB2/issues/692](https://github.com/WebDevStudios/CMB2/issues/692)
 * We are using the following plugins:
    - [https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/javascript/cmb2-js-validation-required.php](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/javascript/cmb2-js-validation-required.php)
    - [https://github.com/WebDevStudios/cmb2-attached-posts](https://github.com/WebDevStudios/cmb2-attached-posts)
    - [https://github.com/jcchavezs/cmb2-conditionals](https://github.com/jcchavezs/cmb2-conditionals)
    - [https://github.com/mustardBees/cmb_field_map](https://github.com/mustardBees/cmb_field_map)
 *  - Here is the code for the field:
    -     ```
          /**
          	 * Repeatable Field Groups
          	 *
          	 * SIDLÄNKAR
          	 */
          	$cmb_group = new_cmb2_box( array(
          		'id'           => $prefix . 'subfeatured_links_metabox',
          		'title'        => __( 'Bassidor', 'cmb2' ),
          		'context'      => 'after_title',
          		'object_types' => array( 'page' ),
          		'show_on'      => array( 'key' => 'page-template', 'value' => array( 'template-landing.php', 'template-poi.php' ) ),
          	) );
          	// $group_field_id is the field id string, so in this case: $prefix . 'demo'
          	$group_field_id = $cmb_group->add_field( array(
          		'id'          => $prefix . 'subfeatured_content',
          		'type'        => 'group',
          		'description' => __( 'Bassidor visas i kolumner längst ned på Landningssidan med Rubrik, Ingress och Länk.', 'cmb2' ),
          		'options'     => array(
          			'group_title'   => __( 'Bassida {#}', 'cmb2' ), // {#} gets replaced by row number
          			'add_button'    => __( 'Lägg till Bassida', 'cmb2' ),
          			'remove_button' => __( 'Ta bort Bassida', 'cmb2' ),
          			'sortable'      => true, // beta
          			'closed'     => false, // true to have the groups closed by default
          		),
          	) );
          	/**
          	 * Group fields works the same, except ids only need
          	 * to be unique to the group. Prefix is not needed.
          	 *
          	 * The parent field's id needs to be passed as the first argument.
          	 */
      
          	$cmb_group->add_group_field( $group_field_id, array(
          		'name'    => __( 'Bassida', 'cmb2' ),
          		'desc'    => __( 'Välj bassida att visa. Rubrik, Ingress och Länk hämtas automatiskt.', 'cmb2' ),
          		'id'      => 'attached_cmb2_attached_posts',
          		'type'    => 'custom_attached_posts',
          		'options' => array(
          			'show_thumbnails' => true, // Show thumbnails on the left
          			'filter_boxes'    => false, // Show a text box for filtering the results
          			'query_args'      => array( 'post_type'=>array( 'page'), 'posts_per_page' => -1, 'post_parent' => $_GET['post'] ), // override the get_posts args
          			'max_attached'    => true
          		),
          	) );
      
             $cmb_group->add_group_field( $group_field_id, array(
          		'name' => 'Anpassa',
          		'id'   => 'custom_content_checkbox',
          		'type' => 'checkbox',
          		'description' => 'Kryssa i denna ruta för att anpassa: Rubrik, Ingress, Länk och/eller Länktext. OBS! Kryssa även i denna rutan om du vill länka till något som inte är en undersida.'
          	) );
      
          	$cmb_group->add_group_field( $group_field_id, array(
          		'name'       => __( 'Anpassad rubrik', 'cmb2' ),
          		'id'         => 'heading',
          		'type'       => 'text',
          		'attributes' => array(
          			'data-conditional-id'    => wp_json_encode( array( $group_field_id, 'custom_content_checkbox' ) ),
          			'data-conditional-value' => 'on',
          		),
          	) );
          	$cmb_group->add_group_field( $group_field_id, array(
          		'name'        => __( 'Anpassad ingress', 'cmb2' ),
          		//'description' => __( '', 'cmb2' ),
          		'id'          => 'content',
          		'type'        => 'textarea_small',
          		'attributes' => array(
          			'data-conditional-id'    => wp_json_encode( array( $group_field_id, 'custom_content_checkbox' ) ),
          			'data-conditional-value' => 'on',
          		),
          	) );
      
          	$cmb_group->add_group_field( $group_field_id, array(
          		'name'       => __( 'Anpassad länk', 'cmb2' ),
          		'id'         => 'link_picked',
          		'type'       => 'link_picker',
          		'attributes' => array(
          			'data-conditional-id'    => wp_json_encode( array( $group_field_id, 'custom_content_checkbox' ) ),
          			'data-conditional-value' => 'on',
          		),
          	) );
          ```
      

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [9 years, 7 months ago](https://wordpress.org/support/topic/sortable-function-isnt-working-for-groups/#post-8387824)
 * Can you go into better detail about exactly what you’re experiencing? I know 
   you point out an issue, but it’s to one that I had the original reporter move
   to the forums here, so there’s a disconnect going on.

Viewing 1 replies (of 1 total)

The topic ‘Sortable Function isn’t working for Groups’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/sortable-function-isnt-working-for-groups/#post-8387824)
 * Status: resolved