Advertisement
romimitu

Functions.php

Jul 30th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. /**** Creating Custom Post *****////
  3. function create_post_type() {
  4.     register_post_type( 'product',
  5.         array(
  6.             'labels' => array(
  7.                     'name' => __( 'Products' ),
  8.                     'singular_name' => __( 'product' ),
  9.                     'add_new' => __( 'Add Product' ),
  10.                     'add_new_item' => __( 'Add Product' ),
  11.                     'edit_item' => __( 'Edit Product' ),
  12.                     'new_item' => __( 'New Product' ),
  13.                     'view_item' => __( 'View Product' ),
  14.                     'not_found' => __( 'Sorry, we couldn\'t find the Product you are looking for.' )
  15.             ),
  16.         'public' => true,
  17.         'publicly_queryable' => true,
  18.         'exclude_from_search' => true,
  19.         'menu_position' => 19,
  20.         'menu_icon' => 'dashicons-cart',
  21.         'has_archive' => true,
  22.         'hierarchical' => true,
  23.         'capability_type' => 'post',
  24.         'rewrite' => array( 'slug' => 'product' ),
  25.         'supports' => array( 'title', 'editor', 'thumbnail' )
  26.         )
  27.     );
  28. }
  29. add_action( 'init', 'create_post_type' );
  30.  
  31. /************ Taxonomy Area *************/
  32.  
  33. function product_taxonomy() {
  34.     register_taxonomy(
  35.         'product_cat',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  36.         'product',                  //post type name
  37.         array(
  38.             'hierarchical'          => true,
  39.             'label'                 => 'product Category',  //Display name
  40.             'query_var'             => true,
  41.             'show_admin_column' => true,
  42.             'rewrite'               => array(
  43.                 'slug'              => 'product-category', // This controls the base slug that will display before each term
  44.                 'with_front'        => false // Don't display the category base before
  45.                 )
  46.             )
  47.     );
  48. }
  49. add_action( 'init', 'product_taxonomy');
  50.  
  51.  
  52.  
  53.  
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement