我创建了名为'event'的CPT,并且工作正常。 但我有其他帖子类型称为'列表'。当我从列表中打开任何帖子然后它将显示帖子类型作为事件我不知道发生了什么。
此帖子的帖子类型为“列表”,并显示为“活动”。正因为这个问题,我的所有条件都变得错误。
任何人都可以帮助我吗?
由于
对于CPT - 事件
//Create Custom Post type (CPT) Event
add_action('init', 'ntvs_register_questions');
function ntvs_register_questions() {
//$icon_url = plugin_dir_url(__FILE__).'/images/askengage_qG1.png';
$labels = array(
'menu_name' => __('Events', 'quest'),
'name' => __('Event', 'quest'),
'add_new' => __('Add New', 'Event'),
'add_new_item' => __('Add New Event'),
'edit_item' => __('Edit Event'),
'all_items' => __('All Events'),
'view_item' => __('View Event')
);
$args = array(
'labels' => $labels,
//'menu_icon' => $icon_url,
'hierarchical' => true,
'description' => 'Holds event & its specific data',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'event'),
'capability_type' => 'post'
);
register_post_type('event', $args);
flush_rewrite_rules();
}
默认PT - 列表
/**
* Post types
*/
$singular = __( 'Job', 'wp-job-manager' );
$plural = __( 'Jobs', 'wp-job-manager' );
if ( current_theme_supports( 'job-manager-templates' ) ) {
$has_archive = _x( 'jobs', 'Post type archive slug - resave permalinks after changing this', 'wp-job-manager' );
} else {
$has_archive = false;
}
$rewrite = array(
'slug' => _x( 'job', 'Job permalink - resave permalinks after changing this', 'wp-job-manager' ),
'with_front' => false,
'feeds' => true,
'pages' => false
);
register_post_type( "job_listing",
apply_filters( "register_post_type_job_listing", array(
'labels' => array(
'name' => $plural,
'singular_name' => $singular,
'menu_name' => __( 'Job Listings', 'wp-job-manager' ),
'all_items' => sprintf( __( 'All %s', 'wp-job-manager' ), $plural ),
'add_new' => __( 'Add New', 'wp-job-manager' ),
'add_new_item' => sprintf( __( 'Add %s', 'wp-job-manager' ), $singular ),
'edit' => __( 'Edit', 'wp-job-manager' ),
'edit_item' => sprintf( __( 'Edit %s', 'wp-job-manager' ), $singular ),
'new_item' => sprintf( __( 'New %s', 'wp-job-manager' ), $singular ),
'view' => sprintf( __( 'View %s', 'wp-job-manager' ), $singular ),
'view_item' => sprintf( __( 'View %s', 'wp-job-manager' ), $singular ),
'search_items' => sprintf( __( 'Search %s', 'wp-job-manager' ), $plural ),
'not_found' => sprintf( __( 'No %s found', 'wp-job-manager' ), $plural ),
'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'wp-job-manager' ), $plural ),
'parent' => sprintf( __( 'Parent %s', 'wp-job-manager' ), $singular )
),
'description' => sprintf( __( 'This is where you can create and manage %s.', 'wp-job-manager' ), $plural ),
'public' => true,
'show_ui' => true,
'capability_type' => 'job_listing',
'map_meta_cap' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => false,
'rewrite' => $rewrite,
'query_var' => true,
'supports' => array( 'title', 'editor', 'custom-fields', 'publicize' ),
'has_archive' => $has_archive,
'show_in_nav_menus' => false
) )
);