wp get top parent category


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.