Menyembunyikan Category Tertentu Dari Widget Categories

Menggunakan widget untuk menampilkan daftar kategori dan ingin menyembunyikan kategori tertentu dari daftar tersebut? Ya, saya tahu kalau widget bawaan wordpress tidak mendukung hal ini. Tapi jangan takut, posting kali ini akan mengajarkan cara menyembunyikannya.

Continue reading “Menyembunyikan Category Tertentu Dari Widget Categories”

Share

Cara Menampilkan Suatu Kategori Pada Page Tersendiri

Pada tulisan terdahulu, kita sudah mempelajari bagaimana caranya agar bisa menghilangkan suatu posting dari homepage. Kali ini, kita akan mempelajari bagaimana menampilkan posting-posting yang dihilangkan tersebut ke suatu halaman tersendiri.

Continue reading “Cara Menampilkan Suatu Kategori Pada Page Tersendiri”

Share

Using in_category To Show Different Template For Different Category In WordPress

When developing sites under wordpress, we, sometime came across condition where we need to show different templates for a particular category/categories. For example, I have a client that need a particular template for his website that is based on wordpress. The site is about restaurant that he own. It has 3 type of posts, regular post for news & events, store items, and menu. For regular post, well, there should be no problem, but for menu, there are several custom fields in actions and the same for store items.

I can go using several if..else or switch(). But, that would produce a bulky single.php which, I try to avoid. There goes, until I found out the simple solution on codex, that is using in_category(). The page also teach me how to implement it smartly. The solution is rather simple. All you have to do is, create several php files which contain codes and add this code inside your single.php:

<?php get_header();

$recipeArrays = array(6,7,8,9,10);
$cateringArrays = array(12,13,14,15,16,17);
$menuArrays = array(18,19,20,21,22,23);
$storeArrays = array(25,26,27,28,29,30);

if(in_category($recipeArrays))
{
	include('single_inner_recipe.php');
}
else if(in_category($cateringArrays))
{
	include('single_inner_catering.php');
}
else if(in_category($menuArrays))
{
	include('single_inner_menu.php');
}
else if(in_category($storeArrays))
{
	include('single_inner_store.php');
}
get_footer(); ?>

That’s it, now you have a more manageable codes.

Share