title: Wordpress - accordion custom ids(categories)
body: <p>I've done custom post type which I named accordion and I did setup a simple accordion with shortcode which works. But now I would like to know how to do allow users to make their own IDs(categories) for accordion and then how to display that category(ID) with shortcode. Cause now as I have it, he displays every new accordion post you make and you cant make different accordions on different pages.</p>
  
  <pre><code>add_action('init', function(){
  
      $labels = array(
          'name' =&gt; _x('accordion', 'post type general name'),
          'singular_name' =&gt; _x('Accordion', 'post type singular name'),
          'add_new' =&gt; _x('Add New Accordion', 'Accordion'),
          'add_new_item' =&gt; __('Add New Accordion'),
          'edit_item' =&gt; __('Edit Accordion'),
          'new_item' =&gt; __('New Accordion'),
          'all_items' =&gt; __('All Accordions'),
          'view_item' =&gt; __('View Accordions'),
          'search_items' =&gt; __('Search Accordions'),
          'not_found' =&gt; __('No Accordion found'),
          'not_found_in_trash' =&gt; __('No Accordion found in Trash'),
          'parent_item_colon' =&gt; '',
          'menu_name' =&gt; 'Accordion'
  
      );
      $args = array(
          'labels' =&gt; $labels,
          'public' =&gt; true,
          'publicly_queryable' =&gt; true,
          'show_ui' =&gt; true,
          'show_in_menu' =&gt; true,
          'query_var' =&gt; true,
          'rewrite' =&gt; true,
          'capability_type' =&gt; 'post',
          'has_archive' =&gt; true,
          'hierarchical' =&gt; false,
          'menu_position' =&gt; null,
          'supports' =&gt; array('title', 'editor', 'thumbnail', 'page-attributes')
      );
      register_post_type('Accordion', $args);
  });
  
  add_shortcode('accordion', function(){
  
      $posts = get_posts(array(
          'numberposts' =&gt; 10,
          'orderby' =&gt; 'menu_order',
          'order' =&gt; 'ASC',
          'post_type' =&gt; 'accordion',
      ));
  
      $accordion  = '&lt;div id="accordion" class="accordion"&gt;'; ///Open the container
      foreach ( $posts as $post ){
  
          $accordion .= sprintf(('&lt;h2&gt;%1$s&lt;/a&gt;&lt;/h2&gt;&lt;div&gt;%2$s&lt;/div&gt;'), // Generate the markup for each Question
              $post-&gt;post_title,
              wpautop($post-&gt;post_content)
          );
      }
  
      $accordion .= '&lt;/div&gt;'; //Close the Container
  
      return $accordion; //Return the HTML
  
  });
  </code></pre>