Title: Shortcode to post custom category posts and count
Last modified: August 31, 2016

---

# Shortcode to post custom category posts and count

 *  [dimavrn1](https://wordpress.org/support/users/dimavrn1/)
 * (@dimavrn1)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-post-custom-category-posts-and-count/)
 * Hello nice Framework!
    I tried to built in new shortcode and i dont know, How
   do I list the names of the categories in select box on new shortcode?
 * this code in my class file
 *     ```
       <?php if (!defined('FW')) die('Forbidden');
   
       class FW_Shortcode_Div extends FW_Shortcode
       {
       	public static function my_thecat() {
       global $post;
       $result = array();
       foreach((get_the_category($post->ID)) as $category) {
       	$result[ $category['cat_name'] ] = $category['name'];
       		}
   
       		return $result;
       }
       }
       ```
   
 * and this in my options file
 * <?php if (!defined(‘FW’)) die(‘Forbidden’);
 * $options = array(
    ‘id’ => array( ‘label’ => __(‘Catname’, ‘{domain}’), ‘desc’
   => __(‘The button label’, ‘{domain}’), ‘type’ => ‘select’, ‘choices’ => FW_Shortcode_Div::
   my_thecat()
 *  )
 * after that in builder shortcode dont show the list of categories in select box/
 * please help
 * [https://wordpress.org/plugins/unyson/](https://wordpress.org/plugins/unyson/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Unyson](https://wordpress.org/support/users/unyson/)
 * (@unyson)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-post-custom-category-posts-and-count/#post-7195230)
 * Hello,
 * Have you [read this](http://manual.unyson.io/en/latest/extension/shortcodes/index.html#creating-a-new-shortcode)?
 *  Thread Starter [dimavrn1](https://wordpress.org/support/users/dimavrn1/)
 * (@dimavrn1)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-post-custom-category-posts-and-count/#post-7195256)
 * I just did not seem to put it right ….
    In your framework, there are shortcode
   display widget aria, and it is possible to choose a dynamic list of sidebars
 *     ```
       <?php if (!defined('FW')) die('Forbidden');
   
       class FW_Shortcode_Widget_Area extends FW_Shortcode
       {
       	public static function get_sidebars()
       	{
       		global $wp_registered_sidebars;
   
       		$result = array();
       		foreach ( $wp_registered_sidebars as $sidebar ) {
       			$result[ $sidebar['id'] ] = $sidebar['name'];
       		}
   
       		return $result;
       	}
       }
       ```
   
 * instructions no how to display dynamic lists in the selection ‘choices’
 *     ```
       <?php if (!defined('FW')) die('Forbidden');
   
       $options = array(
       	'sidebar' => array(
       		'label'   => __( 'Sidebar', 'fw' ),
       		'desc'    => '',
       		'type'    => 'select',
       		'choices' => FW_Shortcode_Widget_Area::get_sidebars()
       	)
       );
       ```
   
 * I want to display a list of all Posts/Pages that are on the site in a dynamic
   list of what code I need to do in a class file?
 *  Thread Starter [dimavrn1](https://wordpress.org/support/users/dimavrn1/)
 * (@dimavrn1)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-post-custom-category-posts-and-count/#post-7195257)
 * How function are displayed list of all posts in site i think it get_posts but
   it don t work

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode to post custom category posts and count’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/unyson_4e6064.svg)
 * [Unyson](https://wordpress.org/plugins/unyson/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/unyson/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/unyson/)
 * [Active Topics](https://wordpress.org/support/plugin/unyson/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/unyson/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/unyson/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [dimavrn1](https://wordpress.org/support/users/dimavrn1/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-post-custom-category-posts-and-count/#post-7195257)
 * Status: not resolved