我们可以在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是本教程开端创建的)
checkbox:
radio:
发表评论
要发表评论,您必须先登录。