Check Whether a page is using WordPress Custom Taxonomy Category

Well, today i faced a little problem on checking whether a page displaying on WordPress site is using a custom taxonomy post type. I need to determine whether that particular page is using a custom taxonomy post type and that particular page is using a particular custom taxonomy post category as well. In this case, i search a bit but couldn’t find this answer easily which resulted me to write this in the case i need this in the future as well.

In order to find whether a particular page is a custom taxonomy category type, we test with the following sentence

 if(is_single()){
          } else if(is_tax('reviews', $term = 'Games')){
            $args = array( 'post_type' => 'reviews', 'showposts' => 72, 'tax_query' => array(
                array(
                        'taxonomy' => 'review_category',
                        'field' => 'slug',
                        'terms' => 'games'
                )
            ) );
          }else if(is_tax('reviews', $term = 'Apps')){
            $args = array( 'post_type' => 'reviews', 'showposts' => 72, 'tax_query' => array(
                array(
                        'taxonomy' => 'review_category',
                        'field' => 'slug',
                        'terms' => 'apps'
                )
            ) );
          }else
            $args = array( 'post_type' => 'reviews', 'showposts' => 72);

My custom taxonomy is ‘reviews’ and i wanted to check whether a particular page is type ‘Apps’ or ‘Games’, this way i am able to determine whether the particular page is using a custom taxonomy category which is different from using is_category which check post category.

 

 

Like this post? Share it!

digg 48 Check Whether a page is using Wordpress Custom Taxonomy Category reddit 48 Check Whether a page is using Wordpress Custom Taxonomy Category stumbleupon 48 Check Whether a page is using Wordpress Custom Taxonomy Category delicious 48 Check Whether a page is using Wordpress Custom Taxonomy Category furl 48 Check Whether a page is using Wordpress Custom Taxonomy Category technorati 48 Check Whether a page is using Wordpress Custom Taxonomy Category google 48 Check Whether a page is using Wordpress Custom Taxonomy Category myspace 48 Check Whether a page is using Wordpress Custom Taxonomy Category facebook 48 Check Whether a page is using Wordpress Custom Taxonomy Category twitter 48 Check Whether a page is using Wordpress Custom Taxonomy Category
share save 171 16 Check Whether a page is using Wordpress Custom Taxonomy Category

No related posts.

About Clay

I am Clay who is the main writer for this website. I own a small web hosting company in Malaysia and i'm available to be hired as individual contractor on elance or odesk. You can find me on twitter.
This entry was posted in How-to, Others and tagged . Bookmark the permalink.

Comments are closed.