Post ve page’lerin yetersiz kaldığı durumlarda Custom Post Type’lara başvuruyoruz. Custom Post Type eklemek için tek yapılması gereken aşağıdaki kodları functions.php içine eklemek. Burada “ürünler” için Post Type oluşturduğumuzu ve çoklu dil desteği verdiğimizi varsayıyorum. Temanın birden fazla dil için kullanılması gerekmiyorsa __ ve _x fonksiyonlarını es geçebilirsiniz. Örneğin;
'name' => __('Products', 'textdomain')
yerine
'name' => 'Ürünler'
kullanabilirsiniz.
function create_product_type() {
$labels = array(
'name' => __('Products', 'textdomain'),
'singular_name' => __('Products', 'textdomain'),
'add_new' => __('Add New Product', 'textdomain'),
'add_new_item' => _x('Add New Product', 'textdomain'),
'edit_item' => __('Edit Product', 'textdomain'),
'new_item' => __('New Product', 'textdomain'),
'view_item' => __('View Product', 'textdomain'),
'search_items' => __('Search Products', 'textdomain'),
'not_found' => __('No Products found', 'textdomain'),
'not_found_in_trash' => __('No Products found in Trash', 'textdomain'),
'parent_item_colon' => '',
'menu_name' => 'Products'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title' , 'custom-fields' , 'editor' , 'comments' ,
'thumbnail' ),
);
register_post_type( 'products', $args );
}
add_action( 'init', 'create_product_type' );