Get Top Parent Category (WordPress)

There are many times when you need to show or get the top most (root) parent category in WordPress - regardless of how many subcategories you might be deep. I have used this logic for page navigation (highlight the top parent tab) - as well as within some custom loops/sidebar code.

They way to do this:

PHP:
  1. <?php
  2. $parentCatList = get_category_parents($cat,false,',');
  3. $parentCatListArray = split(",",$parentCatList);
  4. $topParentName = $parentCatListArray[0];
  5. $sdacReplace = array(" " => "-", "(" => "", ")" => "");
  6. $topParent = strtolower(strtr($topParentName,$sdacReplace));
  7. ?>

To test this you can simply put it in your header and echo out $topParent and you will see the "slug" of the category.
If you want to see the category name and not necessarily the slug - you can simply echo $topParentName.

HTML to PDF

We recently finished a project where we had to create a PDF on the fly of the user's filled out application (~12 pages of data) so they could keep a copy. To do this - I looked at a few libraries out there and then ended up using HTML_toPDF. I had used another script from the same guy who put together HTML_toPDF and thus prompted me to use this one as well. The script works great and our client is very happy. If you ever need this capability - check out HTML_toPDF!

Web Site Portfolio Available

We have recently updated our portfolio and made it available. All of our recent web development work is now available for visitors and potential customers to look at.