---
title: Dodawanie Custom Post Type (CPT)
description: "Kod, który dodaje wpisy własnego typu - Custom Post Type. Przykładowy kod pokazuje jak dodać nowy Custom Post Type - nieruchomości. ``` function init_nieruchomosci(){ $nieruchomosci_args = array( 'labels' => array( 'name' => 'Nieruchomości', 'singular_name' => 'Nieruchomość', 'all_items' => 'Wszystkie nieruchomości',…"
url: "https://www.investnet.pl/baza-wiedzy/dodawanie-custom-post-type-cpt/"
updated: "2022-11-14"
category: Porady i tipy WordPress / Custom Post Type
---

# Dodawanie Custom Post Type (CPT)

Kod, który dodaje wpisy własnego typu - Custom Post Type. Przykładowy kod pokazuje jak dodać nowy Custom Post Type - nieruchomości.

```
function init_nieruchomosci(){
    $nieruchomosci_args = array(
        'labels' => array(
            'name' => 'Nieruchomości',
            'singular_name' => 'Nieruchomość',
            'all_items' => 'Wszystkie nieruchomości',
            'add_new' => 'Dodaj nowe',
            'add_new_item' => 'Dodaj nowe',
            'edit_item' => 'Edytuj',
            'new_item' => 'Nowe nieruchomości',
            'view_item' => 'Zobacz',
            'search_items' => 'Szukaj w nieruchomościach',
            'not_found' => 'Nie znaleziono',
            'not_found_in_trash' => 'Brak',
            'parent_item_colon' => ''
        ),
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => 5,
        'supports' => array(
            'title', 'thumbnail','taxonomies'
        ),
       'has_archive' => true
    );
    
    register_post_type('nieruchomosci',  $nieruchomosci_args);
}
add_action('init', 'init_nieruchomosci');
```
