Query Category Parent
-
Hi,
I am trying to query the parent category of teh post displayed.
I was able to print out that perticular category with the aid from: ERICULOUS.<?php $parentscategory =""; $returnto ="[:en]Return to [:fr]Retourner à"; foreach((get_the_category()) as $category) { if ($category->category_parent == 0) { $parentscategory .= _e(' <a href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $returnto . ' ' . $category->name . '</a> '); } } echo substr($parentscategory,0,-2) ; ?>
But I can’t seem to modify the code to adapt it to a query.
I know it’s probably a simple change in the code to call:
<?php $categoryvariable=$cat; // assign the variable as current category $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query query_posts($query); // run the query ?>
But when I try my page doesn’t get printed at all or I have errors. If somebody could help me out I would definitely appreciate.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Query Category Parent’ is closed to new replies.