mercredi 31 décembre 2014

Wordpress Custom Post Type is not working properly


I'm creating custom WordPress theme and i'm in trouble, i have created the custom post type when i visit the custom post type all styles are gone and when i inspect element that page all html elements are different like classes and div which are not included in that custom post type file.


I'm Searching Google from last one day everyone is saying this problem occurred due to irrelevant use of flush_rewrite_rules(); and i'm using this function only once when theme will change.


When i change the permalinks from admin panel to default everything working great but when i change again permalinks to postname, numeric and month & name same problem occurred all style from custom post type are gone it showing different div and classes when i inspect element that page.


Below is the code for custom post type.



function my_custom_post_product() {

$labels = array(
'name' => _x( 'Portfolios', 'post type general name' ),
'singular_name' => _x( 'Portfolio', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Portfolio' ),
'edit_item' => __( 'Edit Portfolio' ),
'new_item' => __( 'New Portfolio' ),
'all_items' => __( 'Portfolio Items' ),
'view_item' => __( 'View Portfolio' ),
'search_items' => __( 'Search Portfolio' ),
'not_found' => __( 'No portfolio found' ),
'not_found_in_trash' => __( 'No portfolio found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Portfolio'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our products and product specific data',
'public' => true,
'menu_position' => 40,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'portfolio', $args );

}

add_action( 'init', 'my_custom_post_product' );

function mytheme_setup_options () {
my_custom_post_product();
flush_rewrite_rules();
}
add_action('after_switch_theme', 'mytheme_setup_options');




Any kind of help would be appreciated.

Thanks





Aucun commentaire:

Enregistrer un commentaire