Home » How to register custom post Type: | wordpress theme development part-8

How to register custom post Type: | wordpress theme development part-8

Hello  दोस्तों इस पार्ट में हम शिखेंगे की custom post type कैसे register करते है |

// register post type  function register_post_type_for_my_project(){     register_post_type('my_custom_projects',array(         'labels'=>array(             'name'=>__('Our Projects'),             'singular_name'=>__('Our Project')             ),             'public'=>true,             'show_in_nav_menus'=>true,             'has_archive'=>false,             'supports'=>array('title','editor','author','excerpt','comments','revisions','custom-fields')             )          );     } add_action('init','register_post_type_for_my_project');
Code language: PHP (php)

How to list custom post type :

यदि आप कस्टम post type को लिस्ट करना चाहते है तो आपको नीचे दिए गए example को use करना hoga |

More info  

//Listing custom Post     <?php          $wp_all_query  = new wp_query(             array(                'post_type'=>'my_custom_projects',                'post_status'=>'publish',                ));                  $wp_all_query  =   $wp_all_query->posts;         echo "<pre>";                  // Load posts loop.         foreach ($wp_all_query as $my_single_post ) :         //print_r($my_single_post);         echo $my_single_post->post_title;     ?>     <?php endforeach; ?>
Code language: PHP (php)

# If you want to display date in diffrent formate than you can try this refrence