我正在使用自定义分类和自定义帖子类型:
<?php
function my_custom_taxonomies() {
register_taxonomy('block',array('static_content'), array(
'hierarchical' => true,
'label' => array(
'name' => __( 'Blocks' ),
'singular_name' => __( 'Block' ),
'add_new_item' => 'Add New Block',
'edit_item' => 'Edit Block',
'new_item' => 'New Block',
'search_items' => 'Search Block',
'not_found' => 'No Block Found',
'not_found_in_trash' => 'No Block found in trash',
),
'query_var' => true, // enable taxonomy-specific querying
'rewrite' => array( 'slug' => 'block' ), // pretty permalinks for your taxonomy?
)
);
}
add_action('init', 'my_custom_taxonomies', 0);
// === CUSTOM POST TYPES === //
function create_my_post_types() {
register_post_type( 'static_content',
array(
'labels' => array(
'name' => __( 'Static Content' ),
'singular_name' => __( 'Static Content' ),
'add_new_item' => 'Add New Static Content',
'edit_item' => 'Edit Static Content',
'new_item' => 'New Static Content',
'search_items' => 'Search Static Content',
'not_found' => 'No Static Content found',
'not_found_in_trash' => 'No Static Content found in trash',
),
'_builtin' => false,
'public' => true,
'hierarchical' => false,
'taxonomies' => array( 'static_content'),
'supports' => array(
'title',
'editor',
'excerpt'
),
'rewrite' => array( 'slug' => 'static_content', 'with_front' => false )
)
);
}
add_action( 'init', 'create_my_post_types' );
但每次进入仪表板时,我都会看到以下消息:
Warning: strip_tags() expects parameter 1 to be string, array given
在 /home/alex/www/static-wordpress/wp-admin/admin-header.php 第14行
自定义帖子类型只是说Array。
答案 0 :(得分:0)
'标签'数组中的最后一项有逗号 - 它们不应该。 (尽管如此,这只是挑剔)。
如果从functions.php文件中删除这两个函数,错误是否会出现? (即你是否检查过这两个代码块是否会造成问题?)
尝试删除最后一个逗号,看看是否仍然出现错误。我怀疑它会,但也可能从某处开始:)