Thursday 17 July 2014

how to create a custom post type in wordpress

<?php

/// put this code into your theme functions.php file 
add_action('init', 'easy_register_post_type');  //  hook  our function with Wordpress  process/stage

function easy_register_post_type() {

register_post_type(
    'products', array(
        'labels' => array(
            'name' => 'Products',
            'singular_name' => 'Product',
            'add_new' => 'Add new product',
            'edit_item' => 'Edit product',
            'new_item' => 'New product',
            'view_item' => 'View product',
            'search_items' => 'Search product',
            'not_found' => 'No products found',
            'not_found_in_trash' => 'No products found in Trash'
        ),
        'public' => true,
        'supports' => array('title',
           'title',
            'editor',
            'excerpt',
            'custom-fields',
            'revisions',
            'thumbnail'
        ),
        'has_archive' => true,
        'taxonomies' => array()
    )
);
}

?>

No comments :

Post a Comment

Freelance Jobs