Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从要显示在LayersWP builder小部件中的自定义帖子类型中选择多个类别_Php_Html_Wordpress_Forms_Widget - Fatal编程技术网

Php 从要显示在LayersWP builder小部件中的自定义帖子类型中选择多个类别

Php 从要显示在LayersWP builder小部件中的自定义帖子类型中选择多个类别,php,html,wordpress,forms,widget,Php,Html,Wordpress,Forms,Widget,我目前正在开发一个LayersWP子主题,并已注册了一个公文包自定义生成器小部件 在这个小部件中,我希望用户能够选择他们想要显示的类别。例如: “一个用户有多个公文包项目。一个在“艺术”类别中,一个在“设计”类别中,一个在“开发”类别中。”。在主页上,用户只想显示“设计”和“艺术”类别中的投资组合项目 默认的LayersWP小部件只允许您选择一个特定类别来显示,不可能选择多个类别。我想将其构建到我的小部件中,但在LayersWP文档中找不到任何关于它的内容 我有点纠结于如何保存所选的类别 目前这

我目前正在开发一个LayersWP子主题,并已注册了一个公文包自定义生成器小部件

在这个小部件中,我希望用户能够选择他们想要显示的类别。例如:

“一个用户有多个公文包项目。一个在“艺术”类别中,一个在“设计”类别中,一个在“开发”类别中。”。在主页上,用户只想显示“设计”和“艺术”类别中的投资组合项目

默认的LayersWP小部件只允许您选择一个特定类别来显示,不可能选择多个类别。我想将其构建到我的小部件中,但在LayersWP文档中找不到任何关于它的内容

我有点纠结于如何保存所选的类别

目前这是我的代码标记:

 $terms = get_terms( $this->taxonomy );
                    if( !is_wp_error( $terms ) ) { ?>
                        <p class="layers-form-item">
                            <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php echo __( 'Category to Display' , LAYERS_THEME_SLUG ); ?></label>
                            <?php $category_options[ 0 ] ="All";
                            foreach ( $terms as $t ) $category_options[ $t->term_id ] = $t->name;
                            echo $this->form_elements()->input(
                                array(
                                    'type' => 'select',
                                    'name' => $this->get_field_name( 'category' ) ,
                                    'id' => $this->get_field_id( 'category' ) ,
                                    'placeholder' => __( 'Select a Category' , LAYERS_THEME_SLUG ),
                                    'value' => ( isset( $categories ) ) ? $categories : NULL ,
                                    'options' => $category_options
                                ) 
                            ); ?>
                        </p>
                    <?php } // if !is_wp_error ?>
$terms=get\u terms($this->taxonomy);
如果(!is_wp_error($terms)){?>


根据您的要求,您将使用
checkboxs
。它已在layerswp
post小部件中使用

参考访问:
https://github.com/Obox/layerswp/blob/master/core/widgets/modules/post.php#L524

您还可以在Layerswp支持论坛上联系。您可以找到所有对您有帮助的现有问题


相同的参考<代码>http://docs.layerswp.com/forums/question/how-to-set-a-new-field-type-of-multi-select-in-to-grab-the-category-value-in-layers-builder-widgets/

根据您的要求,您将使用
复选框
。它已在layerswp
post小部件中使用

参考访问:
https://github.com/Obox/layerswp/blob/master/core/widgets/modules/post.php#L524

您还可以在Layerswp支持论坛上联系。您可以找到所有对您有帮助的现有问题

相同的参考<代码>http://docs.layerswp.com/forums/question/how-to-set-a-new-field-type-of-multi-select-in-to-grab-the-category-value-in-layers-builder-widgets/