Piklist入门教程十四:checkbox,dropdowns,radio控件显示Post Type

我们可以在Piklist的checkbox、dropdowns、radio控件显示Post type,可以在Piklist创建的Metabox、Settings、Widget中显示,这些控件中的’choices’属性用到wordpress函数的 get_post_types() 该函数将所有用户返回为数组对象来处理,代码如下:

piklist('field', array(
    'type' => 'select'
    ,'field' => 'my_post_types'
    ,'label' => 'Choose a Type'
    ,'choices' => piklist(
        get_post_types(
            array(
                'public' => true
            )
            ,'objects'
        )
        ,array(
            'name'
        ,'label'
        )
    )
));

预览效果:(记得把type改改其他radio checkbox控件,前三个是wordpress默认,Products是本教程开端创建的)

post_type_sel

checkbox:

post_type_checkbox

radio:

post_type_radio

文章分类 Piklist, 经验分享 标签: ,

发表评论


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /var/www/wp/code/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048