Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Kupası
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPress’te Özel Yazı Türleri Nasıl Oluşturulur?

Editoryal Not: WPBeginner üzerindeki ortak bağlantılardan komisyon kazanıyoruz. Komisyonlar, editörlerimizin görüşlerini veya değerlendirmelerini etkilemez. Editoryal Süreç hakkında daha fazla bilgi edinin.

WordPress’te özel yazı türlerini nasıl kolayca oluşturacağınızı öğrenmek ister misiniz?

Özel yazı türleri, yazıların ve sayfaların ötesine geçmenizi ve web siteniz için farklı içerik türleri oluşturmanızı sağlar. WordPress sitenizi bir blog platformundan güçlü bir içerik yönetim sistemine(CMS) dönüştürürler.

Bu makalede, WordPress’te özel yazı türlerini nasıl kolayca oluşturabileceğinizi göstereceğiz.

How to Create Custom Post Types in WordPress

WordPress’te Özel Yazı Türü Nedir?

WordPress web sitenizde, yazı türleri WordPress’teki farklı içerik türlerini ayırt etmeye yardımcı olmak için kullanılır. Yazılar ve sayfaların her ikisi de yazı türüdür ancak farklı amaçlara hizmet etmek için yapılmıştır.

WordPress varsayılan olarak birkaç farklı yazı türüyle birlikte gelir:

  • Posta
  • Sayfa
  • Eklenti
  • Revizyon
  • Nav Menüsü

Özel gönderi türleri olarak bilinen kendi gönderi türlerinizi de oluşturabilirsiniz. Bunlar, standart bir gönderi veya sayfadan farklı bir biçime sahip içerik oluştururken kullanışlıdır.

Örneğin, bir film inceleme sitesi işletiyorsanız, muhtemelen bir film incelemeleri yazı türü oluşturmak istersiniz. Ayrıca portföyler, referanslar ve ürünler için de özel gönderi türleri oluşturabilirsiniz.

WPBeginner’da, günlük blog makalelerimizden ayrı tutmak için Fırsatlar ve Sözlük bölümlerimiz için özel gönderi türleri kullanıyoruz. Bu, web sitesi içeriğimizi daha iyi düzenlememize yardımcı oluyor.

Özel gönderi türleri farklı özel alanlara ve kendi özel kategori yapılarına sahip olabilir.

Birçok popüler WordPress eklentisi, WordPress web sitenizde veri depolamak için özel yazı türlerini kullanır. Aşağıda özel gönderi türlerini kullanan en iyi birkaç eklenti yer almaktadır:

  • WooCommerce çevrimiçi mağazanıza bir ‘ürün’ gönderi türü ekler
  • WPForms, tüm formlarınızı saklamak için bir ‘wpforms’ yazı türü oluşturur
  • MemberPress ‘e ‘memberpressproduct’ özel yazı türü eklendi

Video Eğitimi

Subscribe to WPBeginner

Yazılı talimatları tercih ediyorsanız, okumaya devam edin.

Özel Yazı Türleri Oluşturmam Gerekiyor mu?

WordPress sitenizde özel yazı türleri oluşturmaya başlamadan önce ihtiyaçlarınızı değerlendirmeniz önemlidir. Çoğu zaman aynı sonuçları normal bir yazı veya sayfa ile elde edebilirsiniz.

Sitenizin özel gönderi türlerine ihtiyacı olup olmadığından emin değilseniz, WordPress’te özel bir gönderi türüne veya taksonomiye ne zaman ihtiyacınız olduğuna ilişkin kılavuzumuza bakın.

Bununla birlikte, WordPress’te kendi kullanımınız için özel yazı türlerini nasıl kolayca oluşturabileceğinize bir göz atalım.

Size iki yöntem göstereceğiz ve ayrıca WordPress web sitenizde özel yazı türlerini görüntüleyebileceğiniz bazı yolları ele alacağız.

WPCode Kullanarak Manuel Olarak Özel Yazı Türü Oluşturma

Özel bir gönderi türü oluşturmak için temanızın functions.php dosyasına kod eklemeniz gerekir. Normalde bunu ileri düzey kullanıcılar dışında kimseye önermiyoruz çünkü küçük bir hata bile sitenizi bozabilir. Ayrıca, temanızı güncellerseniz kod silinecektir.

Ancak, WordPress web sitenize özel kod eklemenin en kolay ve en güvenli yolu olan WPCode’u kullanacağız.

WPCode ile özel snippet’ler ekleyebilir ve yüklemiş olabileceğiniz birçok özel veya tek kullanımlık eklentinin yerini alabilecek yerleşik, önceden yapılandırılmış kod kitaplığından birçok özelliği etkinleştirebilirsiniz.

Öncelikle, ücretsiz WPCode eklentisini yüklemeniz ve etkinleştirmeniz gerekecektir. Ayrıntılı talimatlar için bir WordPress eklentisinin nasıl kurulacağına ilişkin adım adım kılavuzumuza göz atın.

Etkinleştirildikten sonra, WordPress panonuzda Kod Parçacıkları “ Parçacık Ekle bölümüne gidin. Farenizi ‘Özel Kodunuzu Ekleyin (Yeni Kod Parçacığı)’ üzerine getirin ve ardından ‘Kod Parçacığını Kullan’a tıklayın.

Add custom code in WPCode with new snippet

Ardından, ‘Özel Snippet Oluştur’ ekranına yönlendirileceksiniz.

Artık kod parçacığınıza bir başlık verebilir ve anahtarı ‘Etkin’ olarak değiştirebilirsiniz.

Creating a custom code snippet using WPCode

Bundan sonra, aşağıdaki kodu ‘Kod Önizleme’ alanına yapıştırın. Bu kod, yönetici kenar çubuğunuzda görünecek ‘Filmler’ adlı temel bir özel gönderi türü oluşturur ve herhangi bir temayla çalışır.

// Our custom post type function
function create_posttype() {
 
    register_post_type( 'movies',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Movies' ),
                'singular_name' => __( 'Movie' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'movies'),
            'show_in_rest' => true,
 
        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

Yalnızca temel bir özel gönderi türü istiyorsanız, Filmler ve Filmler ‘i kendi CPT slug’ınız ve adınızla değiştirin ve ‘Güncelle’ düğmesine tıklayın.

Ancak, özel gönderi türünüz için daha fazla seçenek istiyorsanız, yukarıdaki kod yerine aşağıdaki kodu kullanın.

Aşağıdaki kod ‘Filmler’ özel gönderi türüne revizyon desteği, öne çıkan görseller, özel alanlar gibi daha birçok seçenek eklemekte ve özel gönderi türünü ‘türler’ adlı özel bir taksonomiyle ilişkilendirmektedir.

Not: Bu iki parçacığı birleştirmeyin, aksi takdirde her iki parçacık da aynı özel yazı türünü kaydettiğinden WordPress size hata verecektir. Kaydetmek istediğiniz her ek yazı türü için WPCode kullanarak tamamen yeni bir snippet oluşturmanızı öneririz.

/*
* Creating a function to create our CPT
*/
 
function custom_post_type() {
 
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Movies', 'Post Type General Name', 'twentytwentyone' ),
        'singular_name'       => _x( 'Movie', 'Post Type Singular Name', 'twentytwentyone' ),
        'menu_name'           => __( 'Movies', 'twentytwentyone' ),
        'parent_item_colon'   => __( 'Parent Movie', 'twentytwentyone' ),
        'all_items'           => __( 'All Movies', 'twentytwentyone' ),
        'view_item'           => __( 'View Movie', 'twentytwentyone' ),
        'add_new_item'        => __( 'Add New Movie', 'twentytwentyone' ),
        'add_new'             => __( 'Add New', 'twentytwentyone' ),
        'edit_item'           => __( 'Edit Movie', 'twentytwentyone' ),
        'update_item'         => __( 'Update Movie', 'twentytwentyone' ),
        'search_items'        => __( 'Search Movie', 'twentytwentyone' ),
        'not_found'           => __( 'Not Found', 'twentytwentyone' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentytwentyone' ),
    );
     
// Set other options for Custom Post Type
     
    $args = array(
        'label'               => __( 'movies', 'twentytwentyone' ),
        'description'         => __( 'Movie news and reviews', 'twentytwentyone' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        // You can associate this CPT with a taxonomy or custom taxonomy. 
        'taxonomies'          => array( 'genres' ),
        /* A hierarchical CPT is like Pages and can have
        * Parent and child items. A non-hierarchical CPT
        * is like Posts.
        */ 
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
        'show_in_rest' => true,
 
    );
     
    // Registering your Custom Post Type
    register_post_type( 'movies', $args );
 
}
 
/* Hook into the 'init' action so that the function
* Containing our post type registration is not 
* unnecessarily executed. 
*/
 
add_action( 'init', 'custom_post_type', 0 );

Hiyerarşik değeri false olarak ayarladığımız kısmı da fark edebilirsiniz. Özel yazı türünüzün Yazılar yerine Sayfalar gibi davranmasını istiyorsanız, bu değeri true olarak ayarlayabilirsiniz.

Dikkat edilmesi gereken bir diğer husus da twentytwentyone dizesinin tekrar tekrar kullanılmasıdır, buna Metin Alanı denir. Temanız çeviriye hazırsa ve özel gönderi türlerinizin çevrilmesini istiyorsanız, temanız tarafından kullanılan metin alanını belirtmeniz gerekecektir.

Temanızın metin alanını tema dizininizdeki style.css dosyasının içinde veya yönetici panelinizdeki Görünüm “ Tema Dosyası Düzenleyicisi ‘ne giderek bulabilirsiniz. Metin alanı dosyanın başlığında belirtilecektir.

Finding the textdomain for a theme

Twentytwentyone yerine kendi temanızın Metin Alanını yazmanız yeterlidir.

Değişikliklerden memnun olduğunuzda, ‘Güncelle’ düğmesine tıklamanız yeterlidir; gerisini WPCode halledecektir.

Eklenti ile Özel Yazı Türü Oluşturma

WordPress’te özel bir yazı türü oluşturmanın bir diğer kolay yolu da bir eklenti kullanmaktır. Bu yöntem yeni başlayanlar için önerilir çünkü güvenli ve süper kolaydır.

Yapmanız gereken ilk şey Custom Post Type UI eklentisini yüklemek ve etkinleştirmektir. Daha fazla ayrıntı için, bir WordPress eklentisinin nasıl kurulacağına ilişkin adım adım kılavuzumuza bakın.

Etkinleştirmenin ardından, yeni bir özel gönderi türü oluşturmak için CPT UI ” Gönderi Türleri Ekle / Düzenle ‘ye gitmeniz gerekir. ‘Yeni Yazı Türü Ekle’ sekmesinde olmalısınız.

Create a New Custom Post Type With a Plugin

İlk olarak, özel gönderi türünüz için ‘filmler’ gibi bir slug sağlamanız gerekir. Bu slug URL’de ve WordPress sorgularında kullanılacağından yalnızca harf ve rakam içerebilir. Bunun altında, özel yazı türünüz için çoğul ve tekil adları sağlamanız gerekir.

Bundan sonra, isterseniz ‘Seçilen etiketlere göre ek etiketleri doldur’ yazan bağlantıya tıklayabilirsiniz. Bu, aşağıdaki ek etiket alanlarını otomatik olarak dolduracak ve genellikle size zaman kazandıracaktır.

Şimdi ‘Ek Etiketler’ bölümüne ilerleyebilirsiniz. Bahsettiğimiz bağlantıya tıklamadıysanız, şimdi gönderi türünüz için bir açıklama sağlamanız ve etiketleri değiştirmeniz gerekecektir.

Scroll Down to the Additional Labels Section

Bu etiketler, söz konusu yazı türündeki içeriği yönetirken WordPress kullanıcı arayüzü boyunca kullanılacaktır.

Daha sonra gönderi türü ayarları gelir. Buradan gönderi türünüz için farklı nitelikler ayarlayabilirsiniz. Her seçenek, ne işe yaradığını açıklayan kısa bir açıklama ile birlikte gelir.

Scroll Down to the Post Type Settings Section

Örneğin, bir gönderi türünü sayfalar gibi hiyerarşik yapmamayı veya kronolojik gönderileri tersten sıralamayı seçebilirsiniz.

Genel ayarların altında, bu gönderi türünün hangi düzenleme özelliklerini destekleyeceğini seçme seçeneğini göreceksiniz. Dahil edilmesini istediğiniz seçenekleri işaretlemeniz yeterlidir.

Check the Supports Options You Want to Include

Son olarak, kaydetmek ve özel gönderi türünüzü oluşturmak için ‘Gönderi Türü Ekle’ düğmesine tıklayın.

Hepsi bu kadar. Özel gönderi türünüzü başarıyla oluşturdunuz ve devam edip içerik eklemeye başlayabilirsiniz.

Sitenizde Özel Yazı Türlerini Görüntüleme

WordPress, özel yazı türlerinizi görüntülemek için yerleşik destekle birlikte gelir. Yeni özel yazı türünüze birkaç öğe ekledikten sonra, bunları web sitenizde görüntülemenin zamanı gelmiştir.

Kullanabileceğiniz birkaç yöntem vardır ve her birinin kendine özgü faydaları vardır.

Varsayılan Arşiv Şablonunu Kullanarak Özel Yazı Türlerini Görüntüleme

İlk olarak, Görünüm ” Menüler bölümüne gidebilir ve menünüze özel bir bağlantı ekleyebilirsiniz. Bu özel bağlantı, özel gönderi türünüzün bağlantısıdır.

Add a Custom Link to Your Menu

SEO dostu kalıcı bağlantılar kullanıyorsanız, özel gönderi türünüzün URL’si büyük olasılıkla buna benzer bir şey olacaktır:

http://example.com/movies

SEO dostu kalıcı bağlantılar kullanmıyorsanız, özel gönderi türü URL’niz buna benzer bir şey olacaktır:

http://example.com/?post_type=movies

‘example.com’ yerine kendi alan adınızı ve ‘movies’ yerine özel gönderi türü adınızı yazmayı unutmayın.

Menünüzü kaydedin ve ardından web sitenizin ön ucunu ziyaret edin. Eklediğiniz yeni menü öğesini göreceksiniz ve üzerine tıkladığınızda, temanızdaki archive.php şablon dosyasını kullanarak özel gönderi türünüzün arşiv sayfasını görüntüleyecektir.

Preview of Custom Post Type Menu Item

Özel Yazı Tipi Şablonları Oluşturma

Özel gönderi türünüz için arşiv sayfasının görünümünü beğenmiyorsanız, özel gönderi türü arşivleri için özel bir şablon kullanabilirsiniz.

Tek yapmanız gereken tema dizininizde yeni bir dosya oluşturmak ve adını archive-movies.php koymak. ‘movies’ yerine özel gönderi türünüzün adını yazdığınızdan emin olun.

Başlamak için temanızın archive.php dosyasının içeriğini archive-movies.php şablonuna kopyalayabilir ve ardından ihtiyaçlarınızı karşılayacak şekilde değiştirebilirsiniz.

Artık özel gönderi türünüzün arşiv sayfasına her erişildiğinde, bu şablon onu görüntülemek için kullanılacaktır.

Benzer şekilde, yazı türünüzün tek giriş ekranı için özel bir şablon da oluşturabilirsiniz. Bunu yapmak için tema dizininizde single-movies.php dosyasını oluşturmanız gerekir. ‘movies’ yerine özel gönderi türünüzün adını yazmayı unutmayın.

Temanızın single .php şablonunun içeriğini single-movies.php şablonuna kopyalayarak başlayabilir ve ardından ihtiyaçlarınızı karşılayacak şekilde değiştirmeye başlayabilirsiniz.

Daha fazla bilgi edinmek için WordPress’te özel tekli yazı şablonlarının nasıl oluşturulacağına ilişkin kılavuzumuza bakın.

Özel Yazı Türlerini Ön Sayfada Görüntüleme

Özel gönderi türlerini kullanmanın bir avantajı, özel içerik türlerinizi normal gönderilerinizden ayrı tutmasıdır. Bununla birlikte, isterseniz özel gönderi türlerini web sitenizin ön sayfasında görüntüleyebilirsiniz.

Ücretsiz WPCode eklentisini kullanarak bu kodu yeni bir snippet olarak eklemeniz yeterlidir. Ayrıntılı talimatlar için lütfen bu makalenin manuel olarak kod ekleme bölümüne bakın.

add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
 
function add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type', array( 'post', 'movies' ) );
    return $query;
}

‘movies’ yerine özel gönderi türünüzü yazmayı unutmayın.

Özel Gönderi Türlerini Sorgulama

Kodlamaya aşina iseniz ve şablonlarınızda döngü sorguları çalıştırmak istiyorsanız, bunu nasıl yapacağınız aşağıda açıklanmıştır. Veritabanını sorgulayarak, özel bir gönderi türünden öğeleri alabilirsiniz.

Aşağıdaki kod parçacığını özel gönderi türünü görüntülemek istediğiniz şablona kopyalamanız gerekecektir.

<?php 
$args = array( 'post_type' => 'movies', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args ); 
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?> 
</div>
<?php endwhile;
wp_reset_postdata(); ?>
<?php else:  ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Bu kod, yeni WP_Query sınıfımız için argümanlarda gönderi türünü ve sayfa başına gönderi sayısını tanımlar. Daha sonra sorguyu çalıştırır, gönderileri alır ve bunları döngü içinde görüntüler.

Widget’larda Özel Yazı Türlerini Görüntüleme

WordPress’te son gönderileri görüntülemek için varsayılan bir widget olduğunu fark edeceksiniz, ancak özel bir gönderi türü seçmenize izin vermiyor.

Peki ya yeni oluşturduğunuz yazı türündeki en son girdileri bir widget’ta görüntülemek isterseniz? Bunu yapmanın kolay bir yolu var.

Yapmanız gereken ilk şey Custom Post Type Widgets eklentisini yüklemek ve etkinleştirmektir. Daha fazla ayrıntı için WordPress eklentisi yükleme hakkındaki adım adım kılavuzumuza bakın.

Etkinleştirmenin ardından Görünüm ” Widget ‘lar bölümüne gidin ve ‘Son Yazılar (Özel Yazı Türü)’ widget’ını sürükleyip kenar çubuğuna bırakın.

Recent Custom Post Type Widget

Bu widget, herhangi bir gönderi türünden son gönderileri göstermenizi sağlar. ‘Yazı Türü’ açılır menüsünden özel yazı türünüzü seçmeniz ve istediğiniz seçenekleri belirlemeniz gerekir.

Bundan sonra, ekranın üst kısmındaki ‘Güncelle’ düğmesine tıkladığınızdan emin olun ve ardından widget’ı çalışırken görmek için web sitenizi ziyaret edin.

Preview of Recent Custom Post Type Widget

Eklenti ayrıca arşivleri, takvimi, kategorileri, son yorumları, aramayı ve etiket bulutunu görüntüleyen özel yazı tipi widget’ları sağlar.

Custom Post Type Archives Widget

Umarız bu eğitim WordPress’te özel yazı türlerinin nasıl oluşturulacağını öğrenmenize yardımcı olmuştur. Ayrıca blog trafiğinizi nasıl artıracağınızı öğrenmek veya yaygın WordPress hataları ve bunların nasıl düzeltileceği listemize göz atmak isteyebilirsiniz.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Açıklama: İçeriğimiz okuyucu desteklidir. Bu, bazı bağlantılarımıza tıklarsanız komisyon kazanabileceğimiz anlamına gelir. WPBeginner'ın nasıl finanse edildiğini, neden önemli olduğunu ve nasıl destek olabileceğinizi görün. İşte editoryal sürecimiz.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Ultimate WordPress Araç Kiti

Araç setimize ÜCRETSİZ erişim sağlayın - her profesyonelin sahip olması gereken WordPress ile ilgili ürün ve kaynaklardan oluşan bir koleksiyon!

Reader Interactions

131 yorumBir Cevap Bırakın

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. R Davies says

    You have a syntax error in your second (more detailed) example, code does not work in latest WordPress 7.4.3

    ) Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘custom_post_type’ not found or invalid function name

    Any chance of an update / correction?

    • Robert Stuart says

      On line 31? Yes, that’s normal PHP code.
      “The comma after the last array element is optional and can be omitted. This is usually done for single-line arrays, i.e. array(1, 2) is preferred over array(1, 2, ). For multi-line arrays on the other hand the trailing comma is commonly used, as it allows easier addition of new elements at the end.”

  3. Arias says

    Hello, I have been having problems with this plugin.

    It has disabled the option to create categories and tags,
    I have been looking for an example to place them manually but I still have not found anything.

    I am trying to undo if with this method I can fix the problem but I would greatly appreciate your help.

    • stormonster says

      In your $args array, on the ‘taxonomies’ index, add ‘category’ and ‘post_tag’.
      That should do the trick.

    • Ilija says

      This is why I use my own CMS where I can create new post types in a fraction of a second directly through cms itself. Without any coding, unfortunately big agencies want WordPress developers and have to learn it, seems so complicated..

  4. Sarah A says

    Hi, i’ve succeded to display group of CPT with a specific design in a pop-up when you click on a image like the first one But it opens a new page and when you click out of the pop-up to quit you don’t return to the homepage, and i don’t want that. I want all on the homepage.

    I’ve put the code of the CPT to display as the pop-up on “single-chg_projet.php” and open and close the pop-up with javascript. I’ve already tried to put all the code of single-chg_projet.php on the index, but it display nothing. Or i may be failed somewhere. Please help me. Thanks

  5. Ghulam Mustafa says

    Hi,

    Thanks for the great code. Just a minor correction to the code. The endwhile; statement is missing before else: statement in the Querying Custom Post Types section =)

    • Tony Peterson says

      THIS! Please update your code to reflect this syntax error as it caused me a bit of heartache until I found Ghulam’s comment. It’s working now.

  6. david ben oren says

    how do i clone a post type which has a speicifc table in it, i need to create a seperate post type for other tables.

  7. Megan says

    I’ve downloaded the plugin and want to add two custom post types. 1. Fanfiction for all of my writings and 2. Fanart for all of my art.

    For Fanfiction – I want the ability to link chapters together into a story and be able to upload chapters to a story as I write them.

    For Fanart – I’d like to have the focus be on an image (obviously) with a description underneath it

    Is this article what I need or this something completely different?

    Thanks,
    Megan

  8. Zubair Abbas says

    Hi,

    I simply copied the code to my site’s functions.php. The new post type is visible in the dashboard but when I try to see a post after publishing it, a blank page appears. Later I realised that even the default posts are not opening.

    When I remove the code from functions.php everything works fine again.

    Please help :(

    Thanks,

    Zubair Abbas

    • Jouke Nienhuis says

      If you see a blank page, it often means that you forgot a character. The fact that you see the posts if you delete your custom code, confirms that you have a typo. Check for semi-colons ” ; ” and the opening and closing brackets.
      To see exactly where you made a mistake, you could edit the wp-config file. Look for ERROR REPORTING and set this value to true. After that test again and there you get an error and a line with the omission.

  9. Alex says

    I have created the CPT and is working beautifully, but Google cannot find it even after updating sitemaps, using SEO plugins or fetching on Google Webmaster Tools. Any thoughts on why is that happening?

    • WPBeginner Support says

      It takes Google sometime to start showing new content in search results. Just to be on safe side, check your SEO plugin settings to make sure you are not blocking indexing of your CPTs or CPT archive pages.

      Yönetici

  10. Amunet says

    Creating Custom Post Type can be easy especially with a plugin. The real trick is to show them on the page. Usually you need quite advanced custom development or theme specific plugins like that for Avada.

    Unfortunately there is no universal way to display CPT in WordPress.

    • Jouke Nienhuis says

      Like the author said, but I will repeat the answer.
      In a nutshell create a link in your navigation menu
      Advanced answer in a nutshell: create an archive page and a single page

  11. Chuck says

    Great article. How can you modify single post CPT post info based on the custom taxonomy? For instance:

    Date | Author | Series | Book | Topic

    This is easy to write but I want to figure out how to display a modified post info if one the missing taxonomy of Series, like:

    Date | Author | Book | Topic

    Otherwise the default post info displays as:

    Date | Author | | Book | Topic

  12. Moazam Ali says

    Dear,

    Thanks for the post. I want to make a library of ebooks and want to use custom post type and portfolio to show the thumbnails of books in front end. Can you please guide how i can do that?

  13. Sharon Wallace says

    Hello All,
    This is a great plugin. I’m trying to get the taxonomy to show on the page. I created one called Presenters. You can see it here.

    How can I make that happen?

    Thank you

  14. Dave S. says

    Hi,
    I have created a form (using ArForms plugin) which I need it to be turned into a Post-Type. Do you have any suggestions as to how to accomplish this please?

    Thank you.

  15. Mark Greenway says

    Thanks for this, exactly what I needed to know to help me get to grips with custom post types.

    Mark.

  16. Graham says

    Thank you! Just what I was looking for. It’s amazing how many times I find wordpress work-arounds and then forget how I do them and keep having to come back.

    Much appreciated!

  17. MELAS says

    Dear,

    I don’t have a lot of knowledge about coding. How can I see on the specific page theses Custom post types and taxonomies?

    Thanks in advance!
    MELAS

  18. Vera says

    Hello,
    Thank yo for this beautiful tutorial.
    I have gone and done everything as you said.
    Two things I do not understand:
    1.
    You have specified taxonomy “genre”. Where is that set up? What if I want to make the actual genres underneath that? How do I make them? Where do I see them?
    2.
    I would like to make the menu links to the “Movies” and underneath – sublinks to “Genres”. I can see the “Movies” in the Menu section, each post, like pages. Don’t really need that, but I won’t mind. How to see the “Genres” in there?
    Thank you,
    Vera

    • WPBeginner Support says

      Seems like you have successfully created your custom post type, i.e. Movies. The next step is to create custom taxonomy, Genres. A taxonomy is a way to sort content in WordPress. Categories and tags are two default taxonomies that come built in with WordPress and are by default associated with ‘Posts’. Please see our tutorial on how to create custom taxonomies in WordPress. Follow the instructions in that tutorial to create your custom taxonomy Genres and associate it with the post type movies. Your custom taxonomy will appear below the Movies menu in WordPress admin area.

      Yönetici

  19. Hamed 3daJoo says

    I do All Of This but when i want to public a post by this post type my post types redirects to main page (i Just coppied your code without any changes)
    for example i write this post with Movies post type

    please help me ilove post type but i can’t use it correctly

  20. antonio says

    hi i’m trying to add the snippet of code fort the post type movie… i copied it into functions.php but when i refresh the page nothing is shown. i’m using the twenty fourteen theme… what can be wrong?

  21. Fahd says

    Hi, Custom post types on my wordpress website were working fine from last 2 years. But what happend is when I change the title of post and click update it save other changes too. But if I keep the post title same and make changes in the post, it doesn’t save it. Any recommendations please?

  22. Arup Ghosh says

    I want to create a custom post type coupons with reveal coupon option and the code will link to the store url, can you tell me how can I do that. I don’t have much knowledge about coding.

    • Jouke Nienhuis says

      it is one of the arguments ($args) when defining the custom post type.
      Add ‘menu-icon’ => ‘dashicons-cart’ to the $args list.
      WordPress uses built-in dashicons, but you can also use your own icons.
      More information on this link:

  23. Johan says

    Hi, the excerpt and the custom fields data is not displaying in the front end… any idea of why this is happening?

  24. Bill Querry says

    I forgot to mention, prreferably via code for my functions.php file since that’s where the curernet CPT are defined.

  25. Bill Querry says

    I am looking at a way to add categories to some existing custom post types. Anyone able to point me in the right direction?

    • Jouke Nienhuis says

      You can add new taxonomies to an existing Post Type (custom or not) just by filling in the right post-type when you write the function to create it. Category is just a taxonomy name which includes all posts with a category.
      If you want to make a new category, just click on category on the menu and create a new one.
      Examples of categories are Boats if your post is about boats or planes if your post is about planes. More categories is also possible, just select or add them in the right sidecolumn when you are writing your new post or editing one.
      A post type is not attached or linked to a specific category, a post is.

  26. Robey Lawrence says

    I just tried to use the snippet under
    Querying Custom Post Types,
    and figured out it needs a before the reset.

  27. YassinZ says

    Thanks for the clean handy article
    I just want to use the text editor in the custom post
    so that I can use html tags,

  28. Yassin says

    thanks for such an awesome clear tutorial
    but I’m faceing a problem in displaying the CPT I’m using SEO friendly permalinks when I direct to may website/movies the CPT are duplicated

  29. Aris Giavris says

    Very useful! Thank you.

    I would like to add to every tag of my posts one of the following signs: +, -, +/-. May I?

    If so, then I would like to have the choice to represent the signed tags as follow: all the +tags, all the -tags, all the +/-tags.

    I think I am questioning a lot of things.

  30. Placid says

    Hi,

    I am having a hard time implementing a custom post type correctly. I have searched for a solution for a long time but couldn’t find any. Here’s what I did:

    1. Freshly installed WordPress in my local wamp server (enabled apache rewrite_module first).

    2. Using default theme (twenty fourteen). No plugins installed.

    3. Changed permalinks to “Post name”

    4. In the plugins folder, created a folder named pr_custom_posts and inside that, created a file named pr_custom_posts.php. In the file I created a custom post type. The code is as follows:

    register_post_type();

    //flush_rewrite_rules();

    }

    public function register_post_type () {

    $args = array(

    ‘labels’ => array (

    ‘name’ => ‘Movies’,

    ‘singular_name’ => ‘Movie’,

    ‘add_new’ => ‘Add New Movie’,

    ‘add_new_item’ => ‘Add New Movie’,

    ‘edit_item’ => ‘Edit Movie’,

    ‘new_item’ => ‘Add New Movie’,

    ‘view_item’ => ‘View Movie’,

    ‘search_items’ => ‘Search Movies’,

    ‘not_found’ => ‘No Movies Found’,

    ‘not_found_in_trash’ => ‘No Movies Found in Trash’

    ),

    ‘query_var’ => ‘movies’,

    ‘rewrite’ => array (

    ‘slug’ => ‘movies/’,

    ‘with_front’=> false

    ),

    ‘public’ => true,

    ‘publicly_queryable’ => true,

    ‘has_archive’ => true,

    ‘menu_position’ => 10,

    ‘menu_icon’ => admin_url().’/images/media-button-video.gif’,

    ‘supports’ => array (

    ‘title’,

    ‘thumbnail’,

    ‘editor’

    )

    );

    register_post_type(‘jw_movie’, $args);

    //flush_rewrite_rules();

    }

    }

    add_action(‘init’, function() {

    new PR_Movies_Custom_Post();

    //flush_rewrite_rules();

    });

    ?>

    The Good Thing: The CPT is showing in my admin panel and I can add and view movies there.

    THE PROBLEM: I cannot preview the movies in the front end (By clicking the “view” in the CPT in admin panel). It shows in the front end only when I set permalink to default (http://localhost/wp02/?p=123).

    What I have tried:

    1. Go to permalink, keep permalink settings to “Post name” and Save changes.

    2. Use flush_rewrite_rules() in several places (one by one) in my code. Please see the commented out parts in the code above.

    3. Created a menu item as:

    URL: http://localhost/wp02/movies

    Navigation Label: Movies

    This creates a menu item in the front end but shows “Not Found” when “Movies” link is clicked.

    This is driving me crazy. Can anyone please help on this? I would really appreciate.

    • kikilin says

      I was going crazy too with the same “Not Found” issue, until I tried this: go to Settings > Permalinks and then re-save your settings. I had switched my setting to Default, and then changed it to Post Name (for my project’s needs). After that, links were working as expected.

  31. ceslava says

    Another easy way is just duplicate the archive.php and rename it to archive-movies.php and the same for single.php -> single-movies.php

    Then you can make tweaks to the php files for your theme.

    Best regards

  32. Mik says

    Hi, I’ve been reading and following your posts for so long now, you are amazing, and targeting those missing stuff of beginners… Thank you.

  33. Davide De Maestri says

    This plugin should be okay, but after every upgrade they’ve got some bug. Due to exporting field, or while migrating from local to remote etc… So It’s better to hand-write the code and put into functions.php :D

Bir Cevap Bırakın

Yorum bırakmayı seçtiğiniz için teşekkür ederiz. Lütfen tüm yorumların yorum poli̇ti̇kasi uyarınca denetlendiğini ve e-posta adresinizin yayımlanmayacağını unutmayın. Ad alanında anahtar kelime KULLANMAYIN. Kişisel ve anlamlı bir sohbet edelim.