permalinks - Custom post shows 404 after theme change

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_

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;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745198640a4616215.html

相关推荐

  • permalinks - Custom post shows 404 after theme change

    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_

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信