Custom Post Type Templates not working

Discussion in 'WordPress' started by Tuhin1234, Mar 15, 2017.

  1. #1
    My site Custom Post Type "gallery" not working from right Templates . it work from archive.php Templates . alredy have archive-gallery.php Templates then it not work .


    here is my code
    /* Add Photo Gallery Post types  . ------------------------------------*/
    
    //----------------------------------------------
    //----------register and label gallery post type
    //----------------------------------------------
    $gallery_labels = array(
        'name' => _x('Gallery', 'post type general name', 'bestia' ),
        'singular_name' => _x('Gallery', 'post type singular name', 'bestia' ),
        'add_new' => _x('Add New', 'gallery', 'bestia' ),
        'add_new_item' => __("Add New Gallery", 'bestia' ),
        'edit_item' => __("Edit Gallery", 'bestia' ),
        'new_item' => __("New Gallery", 'bestia' ),
        'view_item' => __("View Gallery"),
        'search_items' => __("Search Gallery", 'bestia' ),
        'not_found' =>  __('No galleries found', 'bestia' ),
        'not_found_in_trash' => __('No galleries found in Trash', 'bestia' ),
        'parent_item_colon' => ''
           
    );
    $gallery_args = array(
        'labels' => $gallery_labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'hierarchical' => true,
        'menu_position' => null,
        'has_archive' => true,
        'can_export'          => true,
        'show_in_admin_bar'   => true,
        'exclude_from_search' => true,
        'capability_type' => 'post',
        'taxonomies' => array( 'post_tag', 'category'),
        'supports' => array('title','editor','custom-fields','thumbnail','comments','excerpt','page-attributes'),
        'menu_icon' => get_bloginfo('template_directory') . '/images/photo-album.png' //16x16 png if you want an icon
    );
    register_post_type('gallery', $gallery_args);
    //----------------------------------------------
    //------------------------create custom taxonomy
    //----------------------------------------------
    add_action( 'init', 'jss_create_gallery_taxonomies', 0);
    function jss_create_gallery_taxonomies(){
        register_taxonomy(
            'phototype', 'gallery',
            array(
                'hierarchical'=> true,
                'label' => 'Photo Categories',
                'singular_label' => 'Category',
                'rewrite' => true
            )
        );   
    }
    PHP:
    i'm use old bestia wp tube theme & theme company not provide old theme support So please help me ....
     
    Tuhin1234, Mar 15, 2017 IP
  2. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #2
    Why not you use Custom Post Type CPT UI instead of writing code your self? It's best I think instead of using own code....
     
    salmanshafiq, Jul 30, 2017 IP