Wordpress

Avinash singh | 6:22 PM

Custom Post Type 

You can generate custom post type by various sites like
http://themergency.com/generators/wordpress-custom-post-types/  and now put the generated code to the functions.php

example

add_action( 'init', 'register_cpt_locations' );

function register_cpt_locations() {

    $labels = array(
        'name' => _x( 'Location', 'locations' ),
        'singular_name' => _x( 'Locations', 'locations' ),
        'add_new' => _x( 'Add New', 'locations' ),
        'add_new_item' => _x( 'Add New Locations', 'locations' ),
        'edit_item' => _x( 'Edit Locations', 'locations' ),
        'new_item' => _x( 'New Locations', 'locations' ),
        'view_item' => _x( 'View Locations', 'locations' ),
        'search_items' => _x( 'Search Location', 'locations' ),
        'not_found' => _x( 'No location found', 'locations' ),
        'not_found_in_trash' => _x( 'No location found in Trash', 'locations' ),
        'parent_item_colon' => _x( 'Parent Locations:', 'locations' ),
        'menu_name' => _x( 'Location', 'locations' ),
    );

    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
       
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
       
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
       
       
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'page'
    );

    register_post_type( 'locations', $args );
}

 Custom Post Type is not working

if custom post type is not working the just go to the Settings-> Permalink and refresh it
http://www.example.com/wp-admin/options-permalink.php

Avinash Kumar Singh © 2013. All Rights Reserved | Powered by-Blogger