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

时间:2017-07-25 13:32:55

标签: 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_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; ?>

有人有什么建议吗?在我的本地站点我没有任何错误..和wp-backend我可以组织分类和发布类型没有问题。 在altervista域上,后端无法正常工作,例如,如果我创建新的分类法,我必须强制页面刷新才能看到它,如果我尝试修改自定义帖子类型ricette以更改分类法错误出现,我必须刷新页面才能看到变化。

提前谢谢

萨拉

0 个答案:

没有答案