Ronald Joseph

I am professional Web Developer working as Professionally and freelancer in Pakistan

How To Create a Custom post Type — March 4, 2014

How To Create a Custom post Type

<code>add_action(‘init’, ‘member’);

function member() {

$labels = array(

‘name’ => _x(‘Our Members’, ‘post type general name’),

‘singular_name’ => _x(‘Our Members’, ‘post type singular name’),

‘add_new’ => _x(‘Add New’, ‘Our Members item’),

‘add_new_item’ => __(‘Add New Our Members Item’),

‘edit_item’ => __(‘Edit Our Members Item’),

‘new_item’ => __(‘New Our Members Item’),

‘view_item’ => __(‘View Our Members Item’),

‘search_items’ => __(‘Search Portfolio’),

‘not_found’ =>  __(‘Nothing found’),

‘not_found_in_trash’ => __(‘Nothing found in Trash’),

‘parent_item_colon’ => ”

);

$args = array(

‘labels’ => $labels,

‘public’ => true,

‘publicly_queryable’ => true,

‘show_ui’ => true,

‘query_var’ => true,

‘menu_icon’ => get_stylesheet_directory_uri() . ‘/images/admin/wp-logo-small.png’,

‘rewrite’ => true,

‘capability_type’ => ‘post’,

‘hierarchical’ => false,

‘menu_position’ => null,

//’supports’ => array(‘title’,’editor’,’author’,’thumbnail’,’post-thumbnails’,’excerpts’,’trackbacks’,’custom-fields’,’comments’,’revisions’,’page-attributes’)

‘supports’ => array(‘title’,’editor’,’thumbnail’,’custom-fields’)

);

register_post_type( ‘member’ , $args );

}

 </code>

 <code>

<?php $index_query = new WP_Query(array( ‘post_type’ => ‘member’, ‘posts_per_page’ => 4 )); ?>

<?php while ($index_query->have_posts()) : $index_query->the_post(); ?>

<?php endwhile; ?></code>