[ create a new paste ] login | about

Link: http://codepad.org/opDNhZPf    [ raw code | output | fork | 1 comment ]

kenjox - PHP, pasted on Sep 10:
<?php

/* Add custom post type */

function product_post_type_init() {
  $labels = array(
    'name' => 'Products',
    'singular_name' => 'Product',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Product',
    'edit_item' => 'Edit Product',
    'new_item' => 'New Product',
    'all_items' => 'All Products',
    'view_item' => 'View Product',
    'search_items' => 'Search Products',
    'not_found' =>  'No Products found',
    'not_found_in_trash' => 'No Products found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Produkter'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor')
  ); 

  register_post_type( 'product', $args );
}
add_action( 'init', 'product_post_type_init' );


/* Add Taxonomies */

/* Product category */
function product_category_init() {
	// create a new taxonomy
	register_taxonomy(
		'product_category',
		'product',
		array(
			'label' => __( 'Produkt Kategori' ),
			'rewrite' => array( 'slug' => 'product-category' ),
			'hierarchical' => true
		)
	);
}
add_action( 'init', 'product_category_init' );

/* Product Brand */
function product_brand_init() {
	// create a new taxonomy
	register_taxonomy(
		'product_brand',
		'product',
		array(
			'label' => __( 'Produkt Brand' ),
			'rewrite' => array( 'slug' => 'product-brand' ),
			'hierarchical' => true
		)
	);
}
add_action( 'init', 'product_brand_init' );

/* Product type*/
function product_type_init() {
	// create a new taxonomy
	register_taxonomy(
		'product_type',
		'product',
		array(
			'label' => __( 'Product Type' ),
			'rewrite' => array( 'slug' => 'product-type' ),
			'hierarchical' => true
		)
	);
}
add_action( 'init', 'product_type_init' );


Output:
1
2

Fatal error: Call to undefined function add_action() on line 38


Create a new paste based on this one


Comments:
posted by shahrukh1998 on Dec 27
add_action( 'init', 'product_post_type_init',0 );

try to replace with above and run again it will work good
reply