WordPress’te kategorileri farklı şekillendirmek mi istiyorsunuz? Çoğu WordPress teması tüm kategori arşiv sayfaları için aynı stili kullanır. Bununla birlikte, zengin içerikli bir web sitesi işletiyorsanız, potansiyellerini en üst düzeye çıkarmak için her kategoriyi farklı şekilde biçimlendirebilirsiniz. Bu makalede, WordPress’te kategorileri kolayca nasıl farklı şekillendirebileceğinizi göstereceğiz.
WordPress’te Kategoriler Neden Farklı Şekillendirilir?
Daha önce de söylediğimiz gibi, çoğu WordPress teması her kategori arşiv sayfası için aynı şablonu kullanır. Bunun nedeni, tema geliştiricilerinin web sitenizdeki kategorileri nasıl kullanacağınızı ve bu kategorilerin neler olacağını bilmemesidir.
Bununla birlikte, zengin içerikli bir site işletiyorsanız, bir kategori arşivi sayfasının düzenini değiştirmek, kullanıcıların o sayfadaki içerikle nasıl etkileşim kuracağı üzerinde önemli bir etkiye sahip olabilir.
Örneğin, bir haber veya dergi sitesi işletiyorsanız, yerel reklamların yerel haberler kategorisinde görüntülenmesini sağlayabilirsiniz. Hava durumu bilgilerini gösterebilir, o kategorideki en popüler hikayeleri gösterebilir vb.
Bunu söyledikten sonra, WordPress’te tek tek kategorileri farklı şekilde nasıl kolayca şekillendirebileceğimizi görelim.
WordPress’te Kategorileri Farklı Şekillendirme
WordPress’te kategorileri şekillendirmenin birden fazla yolu vardır. Kategorileri şekillendirmek için size iki farklı yöntem göstereceğiz ve ihtiyaçlarınıza ve beceri seviyenize en uygun olanı seçebilirsiniz.
WordPress Temasında Tek Kategori Şablonu Kullanma
WordPress temaları standart bir şablon hiyerarşisini takip eder. Bir şablon dosyasının adına bağlı olarak, WordPress bir sayfayı görüntülemek için doğru şablonu otomatik olarak seçebilir.
Örneğin, kategori arşiv sayfalarını görüntülemek için category.php dosyasını arar.
WordPress ayrıca tek tek kategoriler için de şablonlar oluşturmanıza olanak tanır. Diyelim ki ‘Elma’ kategorisini farklı bir şekilde şekillendirmek istiyorsunuz. Bunu temanıza yeni bir şablon dosyası ekleyerek ve category-apple.php olarak adlandırarak yapabilirsiniz.
Bir FTP istemcisi kullanarak WordPress sitenize bağlanın ve ardından /wp-content/themes/your-current-theme/ klasörüne gidin ve yeni bir category-apple.php dosyası oluşturun. Elma yerine kendi kategori adınızı yazmayı unutmayın.
Başlangıç noktası olarak temanızın category.php dosyasını kullanabilirsiniz. Basitçe düzenleyin ve tüm içeriğini kopyalayın. Şimdi yeni oluşturduğunuz category-apple.php dosyasını düzenleyin ve kodu içine yapıştırın.
Bundan sonra bireysel kategori şablonunuzda değişiklikler yapmaya başlayabilirsiniz. Bu kategori için farklı bir kenar çubuğu oluşturabilir ve kullanabilir, tam genişlikte bir sayfa yapabilir, bir hoş geldiniz mesajı ekleyebilir veya istediğiniz herhangi bir şeyi yapabilirsiniz.
WordPress’te CSS Kullanarak Kategorileri Tek Tek Stilize Etme
WordPress, web sitenizdeki farklı öğelere otomatik olarak CSS sınıfları ekler. Bunlar hem gövde sınıfını hem de yazı sınıfını içerir.
Örneğin, bir kategori arşivi sayfasını görüntüler ve ardından İnceleme Aracını kullanırsanız, gövde etiketinde kategori ve kategori adı CSS sınıflarını fark edersiniz.
Bu CSS sınıfını, özel CSS ekleyerek her bir kategoriyi farklı şekilde stilize etmek için kullanabilirsiniz.
Burada başlangıç noktası olarak kullanabileceğiniz bazı örnek CSS’ler bulunmaktadır.
body.category-apple { background-color:#EEE; background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed; color:#FFFFFF; } .category-apple .site { background:#232323; } .category-apple a { color:#CCCCCC; }
CSS sınıfındaki kategori adını kendi kategori adınızla değiştirmeyi unutmayın.
Umarız bu makale WordPress’te kategorileri nasıl farklı şekillendireceğinizi öğrenmenize yardımcı olmuştur. WordPress için en çok aranan kategori hack’leri ve eklentileri listemizi de görmek isteyebilirsiniz.
Bu makaleyi beğendiyseniz, WordPress video eğitimleri için lütfen YouTube Kanalımıza abone olun. Bizi Twitter ve Facebook‘ta da bulabilirsiniz.
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!
ofir says
is it possible to change style of all the post under the category and not just the category archive page, with the css option ?
i want to display:none of an element only on specific category pages
WPBeginner Support says
It is possible but you would need to add some code for adding the category target to posts as that is not a default addition from WordPress.
Yönetici
Caroline says
Thanks for your article!
Let say I want to style all posts in category “Reviews” but only the child-categories in reviews are selected for the post.
How can I style all the child categories in the category Review?
WPBeginner Support says
For what it sounds like you’re wanting, you would want to target the individual subcategories.
Yönetici
Caroline says
Yes that’s correct! Is it possible?
WPBeginner Support says
Apologies for the confusion by what we meant, we would mean following this guide for each of the subcategories and if you wanted to have the subcategories grouped you can add a comma for the CSS to affect an additional target.
Caroline says
Hello,
thank you for the article.
What is going on if an article belongs to two or more categories ?
Carosch
AB says
The question is how to assign a custom category template layout from the admin dashboard to multiple other categories.
for example I’ve created a template called Category-grid.php . how do assign it to multiple categories in my wordpress ?
Kat S. says
Fantastic Article!
I am a WordPress newbie and have been trying to figure out a way to do exactly this. I did run into some problems when following your steps though. Our Wp site is set up on a Windows server running iis 7, so I do not know if that is causing my issue, but I’m sure the issue is on my end, not with your instructions.
I tried both methods; copying category.php to a new php file named after one of my categories, and CSS. CSS worked like a charm, but with the first method, I received an error telling me that a call to a certain function in the original php category file was duplicated in my custom category file. I created the new php file in my child theme directory (I am using Avada). The original category.php was also not found in the location you mention, but in the wp-includes folder. My blog page has been working fine though; and so have my categories. Not sure how to deal with this as there was SO much coding in the original category php file; I have no idea what, if anything, I should have deleted from my custom category php file.
A lot of information I know. Many thanks for responding if you have further suggestions.
Love this site!