admin管理员组文章数量:1415420
i have a custom post created using a plugin. But randomly say if i change the theme the post shows a 404
. I tried flush_rewrite_rules()
and resaving the permalink, theme change but still it shows 404.
add_action( 'init', 'ggowl_custom_template_post', 0 );
function ggowl_custom_template_post(){
$labels = array(
'name' => esc_html_x( 'Templates', 'Post Type General Name', 'ggowl' ),
'singular_name' => esc_html_x( 'Template', 'Post Type Singular Name', 'ggowl' ),
'menu_name' => esc_html__( 'GGOwl Templates', 'ggowl' ),
'name_admin_bar' => esc_html__( 'Post Type', 'ggowl' ),
'archives' => esc_html__( 'Template Archives', 'ggowl' ),
'attributes' => esc_html__( 'Template Attributes', 'ggowl' ),
'parent_item_colon' => esc_html__( 'Parent Template :', 'ggowl' ),
'all_items' => esc_html__( 'All Template', 'ggowl' ),
'add_new_item' => esc_html__( 'Add New Template', 'ggowl' ),
'add_new' => esc_html__( 'Add New', 'ggowl' ),
'new_item' => esc_html__( 'New Template', 'ggowl' ),
'edit_item' => esc_html__( 'Edit Template', 'ggowl' ),
'update_item' => esc_html__( 'Update Template', 'ggowl' ),
'view_item' => esc_html__( 'View Template', 'ggowl' ),
'view_items' => esc_html__( 'View Template', 'ggowl' ),
'search_items' => esc_html__( 'Search Template', 'ggowl' ),
'not_found' => esc_html__( 'Not found', 'ggowl' ),
'not_found_in_trash' => esc_html__( 'Not found in Trash', 'ggowl' ),
'featured_image' => esc_html__( 'Featured Image', 'ggowl' ),
'set_featured_image' => esc_html__( 'Set featured image', 'ggowl' ),
'remove_featured_image' => esc_html__( 'Remove featured image', 'ggowl' ),
'use_featured_image' => esc_html__( 'Use as featured image', 'ggowl' ),
'insert_into_item' => esc_html__( 'Insert into Template', 'ggowl' ),
'uploaded_to_this_item' => esc_html__( 'Uploaded to this Template', 'ggowl' ),
'items_list' => esc_html__( 'Templates list', 'ggowl' ),
'items_list_navigation' => esc_html__( 'Templates list navigation', 'ggowl' ),
'filter_items_list' => esc_html__( 'Filter Templates list', 'ggowl' ),
);
$args = array(
'label' => esc_html__( 'Template', 'ggowl' ),
'description' => esc_html__( 'Create templates', 'ggowl' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'revisions','comments' ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-clipboard',
'show_in_admin_bar' => false,
'show_in_nav_menus' => false,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'ggowl_template', $args );
}
and this is how i have set the template for that custom post type
add_filter('single_template', 'ggowl_template_core');
function ggowl_template_core($single)
{
global $post;
/* Checks for single template by post type */
if ($post->post_type == 'ggowl_template') {
if (file_exists(plugin_dir_path(GGOWL_PLUGIN_FILE) . 'admin/templatereg/core-template/ggowl-template-core.php')) {
return plugin_dir_path(GGOWL_PLUGIN_FILE) . 'admin/templatereg/core-template/ggowl-template-core.php';
}
}
return $single;
}
本文标签: permalinksCustom post shows 404 after theme change
版权声明:本文标题:permalinks - Custom post shows 404 after theme change 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745198640a2647262.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论