• 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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Unyson

    (@unyson)

    Hello,

    Have you read this?

    Thread Starter dimavrn1

    (@dimavrn1)

    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

    (@dimavrn1)

    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.