Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.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
class-wp-post-type.php上的自定义分类法和自定义post类型错误_Php_Wordpress_Custom Post Type_Custom Taxonomy - Fatal编程技术网

class-wp-post-type.php上的自定义分类法和自定义post类型错误

class-wp-post-type.php上的自定义分类法和自定义post类型错误,php,wordpress,custom-post-type,custom-taxonomy,Php,Wordpress,Custom Post Type,Custom Taxonomy,使用自定义分类法,在本地,一切都正常工作,但当我尝试域测试时,会看到错误消息: 为中的foreach()提供的参数无效 第634行的domainsite/wp includes/class-wp-post-type.php 参考错误的634代码行如下所示: /** * Registers the taxonomies for the post type. * * @since 4.6.0 * @access public */ public function register_taxo

使用自定义分类法,在本地,一切都正常工作,但当我尝试域测试时,会看到错误消息:

为中的foreach()提供的参数无效 第634行的domainsite/wp includes/class-wp-post-type.php

参考错误的634代码行如下所示:

/**
 * Registers the taxonomies for the post type.
 *
 * @since 4.6.0
 * @access public
 */
public function register_taxonomies() {
    foreach ( $this->taxonomies as $taxonomy ) {
        register_taxonomy_for_object_type( $taxonomy, $this->name );
    }
}
我在寻找解决方案或解决方法,但我没有找到任何关于我的问题的东西

这是我的分类注册:

    function tipiricetta_taxonomy() {

$labels = array(
    'name'                       => 'Tipiricette',
    'singular_name'              => 'Tipiricetta',
    'menu_name'                  => 'Tipo ricetta',
    'all_items'                  => 'Tutti i tipi ricetta',
    'parent_item'                => 'Genitore tipo ricetta',
    'parent_item_colon'          => 'Genitore tipo ricetta',
    'new_item_name'              => 'Nuovo tipo ricetta',
    'add_new_item'               => 'Aggiungi nuovo tipo',
    'edit_item'                  => 'Modifica tipo ricetta',
    'update_item'                => 'Aggiorna tipo ricetta',
    'view_item'                  => 'Visualizza tipo ricetta',
    'separate_items_with_commas' => 'Separa tipo ricetta con virgola',
    'add_or_remove_items'        => 'Aggiungi o rimuovi tipo ricetta',
    'choose_from_most_used'      => 'Scegli dai più utilizzati',
    'popular_items'              => 'Tipi ricetta popolari',
    'search_items'               => 'Cerca tipo ricetta',
    'not_found'                  => 'Non trovato',
    'no_terms'                   => 'Nessun tipo ricetta',
    'items_list'                 => 'Lista tipo ricetta',
    'items_list_navigation'      => 'Naviga tipo ricetta',
);
$rewrite = array(
    'slug'                       => '',
    'with_front'                 => true,
    'hierarchical'               => false,
);
$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => false,
    'show_tagcloud'              => false,
    'rewrite'                    => $rewrite,
);register_taxonomy( 'tipiricetta', array( 'ricette' ), $args );}add_action( 'init', 'tipiricetta_taxonomy', 0 );
这是我的自定义帖子类型

// Register Custom Post Type


function ricette_post_type() {
    $labels = array(
    'name'                  => 'Ricette',
    'singular_name'         => 'Ricetta',
    'menu_name'             => 'Ricette',
    'name_admin_bar'        => 'Ricette',
    'archives'              => 'Archivio ricette',
    'attributes'            => 'Attributi ricetta',
    'parent_item_colon'     => 'Genitore ricetta',
    'all_items'             => 'Tutte le ricette',
    'add_new_item'          => 'Aggiungi nuova ricetta',
    'add_new'               => 'Aggiungi nuova',
    'new_item'              => 'Nuova ricetta',
    'edit_item'             => 'Modifica ricetta',
    'update_item'           => 'Aggiorna ricetta',
    'view_item'             => 'Visualizza ridetta',
    'view_items'            => 'Visualizza ricette',
    'search_items'          => 'Cerca ricette',
    'not_found'             => 'Non trovata',
    'not_found_in_trash'    => 'Nono trovata nel cestino',
    'featured_image'        => 'Immagine in evidenza',
    'set_featured_image'    => 'Imposta immagine in evidenza',
    'remove_featured_image' => 'Rimuovi immagine in evidenza',
    'use_featured_image'    => 'Usa come immagine in evidenza',
    'insert_into_item'      => 'Inserisci nella ricetta',
    'uploaded_to_this_item' => 'Carica nella ricetta',
    'items_list'            => 'Lista ricette',
    'items_list_navigation' => 'Naviga lista ricette',
    'filter_items_list'     => 'Filtra lista ricette',
);
$rewrite = array(
    'slug'                  => 'ricette',
    'with_front'            => false,
    'pages'                 => true,
    'feeds'                 => true,
);
$args = array(
    'label'                 => 'Ricetta',
    'description'           => 'Ricette',
    'labels'                => $labels,
    'supports'              => array( 'title', 'editor', 'excerpt', 'thumbnail',),
    'hierarchical'          => false,
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 5,
    'menu_icon'             => 'dashicons-carrot',
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => 'ricette',
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'rewrite'               => $rewrite,
    'capability_type'       => 'page',
    'taxonomies'            => 'tipiricetta'
);register_post_type( 'ricette', $args );}add_action( 'init', 'ricette_post_type', 0 );
这是我的循环:

<?php if (have_posts()): ?>
                <?php while (have_posts()):the_post(); ?>

                    <?php
                    $terms = wp_get_post_terms(get_the_ID(), 'tipiricetta');
                    $output = array();
                    $classi = "";
                    foreach ($terms as $val) {
                        $output[] = '<a href="' . get_term_link($val) . '">' . $val->name . '</a>';
                        $classi .= $val->slug . ' ';
                    }
                    ?>......<?php endwhile; ?>

......
有人有什么建议吗?在我的本地站点中,我没有任何错误。而且,我可以毫无问题地组织分类法和文章类型。 在altervista域上,后端无法正常工作,例如,如果我创建了一个新的分类法,我必须强制页面刷新以查看它,如果我试图修改自定义的post类型ricette以更改分类法,则会出现错误,我必须刷新页面以查看更改

先谢谢你


Sara

您是否已在测试域上发布帖子或向帖子类型和自定义分类添加数据?是的,我已在域测试中向帖子类型和自定义分类添加数据。。现在我已经在本地网站上设置了调试,我也在本地主机网站上看到了错误…如果你想看到,我可以给你在线域测试的路径:这是自定义帖子类型的页面我找到了解决方案,在注册自定义帖子类型中分类法需要以下代码:'taxonomies'=>array('tipiricetta'),