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 Taksonomilere Özel Meta Alanlar Nasıl Eklenir?

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 taksonomilere özel meta alanlar eklemeniz mi gerekiyor?

Özel taksonomiler, içeriğinizi kategoriler ve etiketlerin ötesinde düzenlemenizi sağlar. Bazen bunları tanımlamak için ek alanlar eklemek yararlı olabilir.

Bu makalede, oluşturdukları taksonomilere nasıl ek meta alanlar ekleyeceğinizi göstereceğiz.

How to Add Custom Meta Fields to Custom Taxonomies in WordPress

Özel Meta Alanları Özel Bir Taksonomiye Ne Zaman Eklemelisiniz?

WordPress web sitenizde yeni içerik oluşturduğunuzda, bunu iki varsayılan taksonomi olan kategoriler ve etiketler kullanarak düzenleyebilirsiniz.

Bazı web siteleri özel taksonomilerin kullanımından yararlanır. Bunlar, içeriğinizi ek şekillerde sıralamanıza olanak tanır.

Örneğin, kitap incelemeleri yayınlayan bir web sitesi, ziyaretçilerin ilgilendikleri incelemeleri hızlı bir şekilde bulabilmeleri için ‘Konular’ ve ‘Yazarlar’ taksonomilerini ekleyebilir.

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

Her taksonomi varsayılan olarak yalnızca üç veya dört alana sahiptir: ad, slug, üst (hiyerarşik ise) ve açıklama.

Taxonomies Have 3 or 4 Fields by Default

Bazen taksonomiyi daha iyi tanımlamak için ek alanlar eklemek yararlı olabilir. Örneğin, ‘yazarlar’ taksonomisine bir ‘doğum yılı’ alanı ekleyebilirsiniz.

Bununla birlikte, WordPress’te özel taksonomilere özel meta alanların nasıl ekleneceği aşağıda açıklanmıştır.

Adım 1: WordPress’te Özel Taksonomilere Özel Meta Alanları Ekleme

Öncelikle Advanced Custom Fields eklentisini yüklemeniz ve etkinleştirmeniz gerekir. Daha fazla bilgi edinmek için WordPress eklentisinin nasıl kurulacağına ilişkin adım adım kılavuzumuza bakın.

Ardından, Özel Alanlar ” Yeni Ekle sayfasına gidin. Burada bir veya daha fazla yeni alan içeren bir alan grubu ekleyebilirsiniz.

Alan grubuna bir başlık vermeniz istenecek ve taksonomi eklenirken veya düzenlenirken bu başlık yeni alanlarla birlikte görüntülenecektir. Bu eğitimde, Yazarlar taksonomisine özel bir alan eklemek istiyoruz, bu nedenle alan grubunu ‘Yazar Ayrıntıları’ olarak adlandıracağız.

Add New Field Group

Bunu yaptıktan sonra, bir alan eklemek için ‘+ Alan Ekle’ düğmesine tıklamalısınız. Yeni alanın ayrıntılarını doldurabileceğiniz yeni bir form görünecektir.

Bir alan etiketi girdiğinizde, alan adı sizin için otomatik olarak oluşturulur ve isterseniz düzenleyebilirsiniz. Alan adını eğitimin ilerleyen bölümlerinde kullanmanız gerekecektir, bu nedenle not alın.

Add New Field

Şimdi alan türü, formu dolduracak yazarlarınız için talimatlar ve bu alanın gerekli olup olmadığı gibi alanla ilgili diğer ayrıntıları doldurmalısınız. Ekran görüntüsünde gösterilmeyen diğer seçenekler arasında varsayılan metin, yer tutucu metin, karakter sınırı ve daha fazlası bulunur.

İkinci bir alan eklemek isterseniz, ‘+ Alan Ekle’ düğmesine tıklamalı ve işlemi tekrarlamalısınız. Aksi takdirde, Konum bölümüne kaydırmanız yeterlidir.

Burada yeni alanın nerede görüntüleneceğini açıklayan kurallar oluşturabilirsiniz. İlk açılır menüden ‘Taksonomi’yi seçmeli ve orta alanı ‘eşittir’ olarak bırakmalısınız. Son olarak, son alan için doğru özel taksonomiyi seçin. Bu eğitimde ‘Yazar’ı seçeceğiz.

Custom Meta Field Location

Bu alanı başka bir taksonomiye eklemek istiyorsanız, ‘Kural grubu ekle’ düğmesine tıklayabilir ve adımı tekrarlayabilirsiniz.

Şimdi sayfadaki diğer ayarları yapmalısınız. Biz sadece varsayılan değerleri bırakacağız. İşiniz bittiğinde sayfanın en üstüne gidin ve ‘Yayınla’ düğmesine tıklayın.

When Finished, Publish the Field Group

Tebrikler, WordPress’te özel bir taksonomiye özel bir meta alanı başarıyla eklediniz. Ancak hala yapmanız gereken bazı işler var.

Adım 2: Yeni Özel Meta Alanına Veri Ekleme

Taksonomi yeni bir alana sahip olsa da henüz herhangi bir veri içermiyor. Şimdi bunu yapmak için biraz zaman ayırmalısınız.

Örneğimizde, her yazar için doğum yılını girmemiz gerekiyor. Bunu yapmak için Mesajlar ” Yazarlar bölümüne gitmemiz ve düzenlemek istediğimiz yazarın adına tıklamamız gerekiyor.

Click on the Custom Taxonomy in Your Admin Menu

Bundan sonra, yeni alana veri girebiliriz. Bu durumda, söz konusu yazarın doğum yılını gireceğiz. Yeni verileri kaydetmek için ‘Güncelle’ düğmesine tıklamayı unutmayın.

Enter Data Into the New Field

Özel taksonominize veri eklemek için web sitenizde de aynı adımları izlemelisiniz.

İşiniz bittiğinde, hala atmanız gereken bir adım var. WordPress yönetici alanınızda oturum açtığınızda özel alanı görebilseniz de, web sitenizin ziyaretçileri bunu göremeyecektir. Alanı özel taksonominin arşiv sayfasına eklemeniz gerekecektir.

Adım 3: Taksonomi Arşiv Sayfanızda Özel Meta Alanı Görüntüleme

Bu adımda, tema dosyalarınıza kod eklemeniz gerekecektir. Bunu daha önce yapmadıysanız, web’den parçacıkların WordPress’e nasıl yapıştırılacağına ilişkin başlangıç kılavuzumuza bakın.

Yapmanız gereken ilk şey temanızın klasörüne girmek ve taksonomi arşiv dosyanızı aramaktır. Taxonomy-YOURTAXONOMYNAME.php gibi bir ada sahip olacaktır.

Örneğin, ‘yazarlar’ adında özel bir taksonominiz varsa, taxonomy-authors.php adında bir dosya aramanız gerekir.

Eğer bu dosyayı göremiyorsanız, archive.php dosyasını arayın. Bu dosyanın bir kopyasını oluşturmanız ve yukarıda açıklandığı gibi adlandırmanız gerekecektir.

Not: Temanız archive.php içermiyorsa, muhtemelen bir WordPress tema çerçevesi kullanıyorsunuzdur ve taksonomi arşivini manuel olarak oluşturmanız gerekecektir. Arşiv dosyalarının nasıl oluşturulacağını öğrenmek için iyi bir başlangıç noktası, WordPress’te özel arşiv sayfalarının nasıl oluşturulacağına ilişkin kılavuzumuzdur.

Şimdi aşağıdaki kodu döngüden hemen önce taksonomi arşivine eklemeniz gerekir:

<?php

// get the current taxonomy term
$term = get_queried_object();

// get the taxonomy meta field
$taxonomymetafield = get_field('FIELDNAME', $term);

// display the taxonomy meta field
echo $taxonomymetafield;

?>

‘FIELDNAME’ yerine yukarıda oluşturduğunuz gerçek alan adını yazmanız gerektiğini unutmayın. Unutmayın, sizden bunu not etmenizi istemiştik.

Örneğimizde, alan adı ‘year_of_birth’. Ziyaretçilerimizin alanın ne anlama geldiğini anlaması için bir açıklama da ekleyeceğiz. Bu yüzden aşağıdaki kodu taxonomy-authors.php taksonomi arşiv dosyasına ekleyeceğiz:

<?php

// get the current taxonomy term
$term = get_queried_object();

// get the taxonomy meta field
$taxonomymetafield = get_field('year_of_birth', $term);

// display the taxonomy meta field
echo "Year of birth: ";
echo $taxonomymetafield;

?>

İşte demo sitemizde test ettiğimizde nasıl göründüğü:

Custom Meta Field Preview

Umarız bu eğitim WordPress’te özel taksonomilere özel meta alanların nasıl ekleneceğini öğrenmenize yardımcı olmuştur. Ayrıca WordPress’te anahtar kelime ve meta açıklama eklemeyi öğrenmek veya sitenizi büyütmek için mutlaka sahip olmanız gereken eklentiler 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

46 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. Tarek Anandan says

    If you can’t your data to display and you’re using a recent version of WordPress, use get_term_meta() instead of get_tax_meta().

  3. Subin says

    here’s my code:
    $config = array(
    ‘id’ => ‘tax_meta_box’, // meta box id, unique per meta box
    ‘title’ => ‘Tax Meta Box’, // meta box title
    ‘pages’ => array(‘category’), // taxonomy name, accept categories, post_tag and custom taxonomies
    ‘context’ => ‘normal’, // where the meta box appear: normal (default), advanced, side; optional
    ‘fields’ => array(), // list of meta fields (can be added by field arrays)
    ‘local_images’ => false, // Use local or hosted images (meta box images for add/remove)
    ‘use_with_theme’ => get_template_directory_uri() . ‘/Tax-Meta-Class/Tax-meta-class’
    );
    /*
    * Initiate your meta box
    */
    $my_meta = new Tax_Meta_Class($config);
    //Image field
    $my_meta->addImage(‘image_field’,array(‘name’=> __(‘My Image ‘,’tax-meta’)));

    $my_meta->Finish();
    ———————————————————————————————————————–
    term_id;
    $saved_data = get_tax_meta($term_id,’image_field’,true);
    echo ”;
    echo $term_id; // Echoes ‘1’ which is the category ID
    echo $saved_data; // Doesn’t show anything . Wonder Why!!
    exit;

    ?>

  4. James Dower says

    I’m also having issues getting the path for an uploaded image. It just echos:

    Array

    …text fields are fine.

    I’m using:

    $prefix = ‘ttp_’;

    $my_meta->addImage($prefix.’logo_id’,array(‘name’=> __(‘Logo’,’tax-meta’)));

    And on the taxonomy.php page:

    $logo = get_tax_meta($term->term_id, ttp_logo_id);

    Can anyone help please? I’ve been at this for HOURS!

  5. James Dower says

    For all those struggling to get this to read out, I found a stray apostrophe in there, this works for me:

    $data = get_tax_meta($term->term_id, ba_text_field_id);
    echo $data;

  6. Ketan says

    Hi,

    I am activate plugin. but i don’t show where i can add custom taxonomy filed in admin side. please replay me.

    Thanks,
    Ketan.

  7. Francisco says

    Thanks a lot this has been very useful!!!! :D

    I displayer correclty a text field using this code:
    //Get the correct taxonomy ID by slug
    $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );

    //Get Taxonomy Meta
    $saved_data = get_tax_meta($term->term_id,’ba_text_field_id’);
    echo $saved_data;

    BUT I need to display an image too, I’m using this php code in my template:

    //Get the correct taxonomy ID by slug
    $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );

    //Get Taxonomy Meta
    $saved_data = get_tax_meta($term->term_id,’ba_image_field_id’);
    echo $saved_data;

    But it doesn’t display anything! :(

    It just shows a single word “array”

    What could be wrong?

  8. Hemanta Chakladar says

    I’m stuck.

    I can see meta data option in wordpress category and not in my custom taxonomy. Where can I add this option to add custom meta in my custom taxonomy ? Where that is defined ?

  9. Joe Chow says

    thanks a lot.I can see there are bunch of fields showed at the post category. However, I just want to know how to make the code to be used for woocommerce product category only.

    Can anyone give a tip?

  10. Jason Gateman says

    Thanks for this tutorial! How do I get the meta to show on a custom post page I have created as opposed to just the taxonomy page?

  11. AD says

    Hi Guys,

    For those who are having issues with displaying the content that is saved. Use the prefix in front of the key.

    //Get Taxonomy Meta
    $saved_data = get_tax_meta($term->term_id,’text_field_id’);
    echo $saved_data;

    That should be ba_text_field_id (Given that the prefix is ba_) .

    Hope this helps cheers.

    • Dan says

      I wanted to second this comment, as it can be quite puzzling to figure out why the example doesn’t work. If you look in the “Tax meta class” file you will see at the top that Ohad defines a $prefix variable that is appended to each save function.

      So in order to get the result to echo out, you need to include the prefix. You can set the prefix to anything you want, including “”. I have no idea what “ba_” stands for, but that is what is in there by default.

      The example should read:
      $saved_data = get_tax_meta($term->term_id,’ba_text_field_id’);

  12. Ante says

    Ok, I’m stuck.

    //Get the correct taxonomy ID by slug
    $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );

    //Get Taxonomy Meta
    $saved_data = get_tax_meta($term->term_id,’text_field_id’);
    echo $saved_data;

    So ‘taxonomy’ is my custom taxonomy, let’s say ‘project_clients’
    ‘text_field_id’ is the id of input field, it’s $prefix.’text_area’…

    What’s ‘term’ ?????

    • Steve says

      Ante,
      Have you had any progress with this??

      I’m wondering the same question – poured over so many comments and pages talking about this, but cannot find a resolution. Any help would be appreciated if you have found the answer.

      Simply adding the following to my taxonomy.php file is not working:

      //Get the correct taxonomy ID by slug
      $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );

      //Get Taxonomy Meta
      $saved_data = get_tax_meta($term->term_id,’text_field_id’);
      echo $saved_data;

  13. fp-admin says

    I am trying to add whatever I put in the WYSIWYG to the front end of the website. I honestly have no clue what I’m doing but this is my code so far:

    term_id,’wysiwyg_field_id’);

    ?>

    <a href="”>

  14. ELiane says

    Hi,

    I used the plugin but I can get the code on my Taxonomy.php.

    I Use this code to display the field

    term_id,’text_field_id’);
    echo $saved_data;

    ?>
    Do I have to do something else?

    Thanks

  15. Tejas Deshmukh says

    Hello, Specially Thanks for this Idea. This plugin is working superb. I have added three extra fields in Perticular Term add, edit option. but when i create category in it at that term at that time I can’t store value for that extra three fields. So any suggestion for that?

  16. Kisshomaru says

    Brilliant! You have no ideea how much time I spent looking for a way to add “quantities” to “products”. This not being a commerce site, it was cumbersome to have a food post tied to an Ingredients taxonomy and not to be able to modify the number of cucumbers for each post.
    Thank You!

  17. Mike Jackson says

    Hi – I’m having trouble getting this to work. I have the data fields visible in my custom taxonomy but I cannot call the data in my brand-description.php using the php code you pasted at the bottom of your article. It doesn’t show an error, it just doesn’t work.

    I’d really appreciate some further explanation with this if you have the time.

    Thanks

  18. Mike Jackson says

    This is quite a find! Been trying to solve this for a few weeks. Any idea how to add the new fields to the columns?

    • Mike Jackson says

      I’m also having trouble outputting anything on the page. I have this code applied and data in the fields but nothing showing on the site

      term_id,’textarea_field_id’);
      echo $saved_data;

      ?>

      • Editorial Staff says

        This code works on taxonomy archive page. If it is not displaying then chances are that the code is not able to get the taxonomy ID. At least that would be my guess.

        -Syed

        Yönetici

  19. FJ says

    Well, this sounds nice and did the trick on the categories but for any reason, it didn’t on a custom taxonomy of mine. Did I miss something ? Is there a hook somewhere I didn’t look at ?
    Anyway thanks a lot for those enlightening on Ohad’s work. I hanged around it wondering how on earth I could use it properly. I’m just the do-it-yourself type, not a real developper, I’m sure you’ll have understood already.
    Thanks again.

      • Ben says

        To clarify – Line 24 of taxonomy-fields.php

        ‘pages’ => array(‘category’), // taxonomy name, accept categories, post_tag and custom taxonomies

        CHANGE the XXX to whatever your custom taxonomy is called
        ‘pages’ => array(‘xxxxx’), // taxonomy name, accept categories, post_tag and custom taxonomies

      • Kobbe says

        Thanks editor i really appreciate for the reply, This is how class-usage-demo.php – http://pastebin.com/ctZPeS0w

        This is what i’m doing but not displaying/outputting anything what am i doing wrong..? and is it possible to display the code (if possible) anywhere in my theme…Thanks

        • Editorial Staff says

          The code you have is simply setting up the admin side of things. To display the code, look at the PHP code that we have shared in the article. You have to use that in your taxonomy archive file.

  20. Michelle says

    Oh thanks you so much, I’ve been wondering how to identify tags as being English or Spanish for my bilingual site – this helps enormously :-)

  21. Jaime says

    I actually just finished coding up custom fields for a custom taxonomy for a project I’m working on. I love the flexibility – will certainly check out the plugin for future projects!

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.