Title archive.php untuk Custom Taxonomy WordPress

Written by Fikri Rasyid

Kategori punya single_cat_title() dan tag punya single_tag_title() untuk memanggil nama dari kategori / tag tersebut di template archive.php. Lalu bagaimana dengan custom taxonomy?

Solusinya saya dapat dari diskusi di forum support WordPress: http://wordpress.org/support/topic/taxonomy-title-output?replies=7

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo $term->name;

kalau anda ingin menampikan deskripsi dari custom taxonomy tersebut, ganti $term->name menjadi $term->description sehingga menjadi seperti ini:

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var(  'taxonomy' ) );
echo $term->description;

Bagaimana dengan conditional tags-nya? Gunakan is_tax() atau misalnya is_tax('book') untuk custom taxonomy tertentu.

About The Author

Fikri Rasyid - I speak HTML + CSS + jQuery, breath in world wide WordPress-land, co-founded WPNest and currently pursuing my bachelor degree majoring English Education at Indonesia University of Education. Google my name for more information about me.

Connect & Subscribe

Keep in touch and get my latest content trough:

Categories

Post Info

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>