get parent id wordpress


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

Get parent id of a category in the category template


Copy this code and paste it in your HTML
  1. <?php
  2. //get parent id
  3. $current_cat_id = get_query_var('cat');
  4. $child = get_category($current_cat_id);
  5. $parent = $child->parent;
  6. //
  7. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.