can you really know what is the first category queried inside a wordpress URL?


My Groups hierarchy is one thing Like

Parent Cat 1
Parent Cat 2
Parent Cat 3
  Subcat 1
  Subcat 2
  Subcat 3
Parent Cat 4
  Subcat 1
  Subcat 2
  Subcat 3

What i am attempting to do would be to echo the "mycat" value in archive.php, to perform a conditional much like:

if($value =="mycat") else

Why it's a bit complicated? because each publish goes to a minimum of 1 sub-cat from each parent plus one of the parent category without any children's.

I want something such as $cat = get_query_var('cat') (within this situation $cat returns mysubcat)

Any Ideas?

Thanks a lot!!

The simplest way to do this is:

$elms = explode('/', $uri) ;
$firstcat = $elms[2] ;

if($firstcat == "products") {

// We show products grid


elseif($firstcat == "accesories") {

// We Show accesories grid


else {

// Whatever!