Skip to content

Instantly share code, notes, and snippets.

@ryanve
Last active December 8, 2016 07:08
Show Gist options
  • Select an option

  • Save ryanve/de28f1b9f70c49de2a19 to your computer and use it in GitHub Desktop.

Select an option

Save ryanve/de28f1b9f70c49de2a19 to your computer and use it in GitHub Desktop.
wordpress check if in category or parent category
<?php
$in_category = function($cats) {
if (in_category($cats)) return true;
foreach ((array) $cats as $cat) {
$subs = get_term_children((int) $cat, 'category');
if ($subs && in_category($subs)) return true;
}
return false;
};
@ryanve

ryanve commented Dec 27, 2015

Copy link
Copy Markdown
Author

@prasanna1311995

Copy link
Copy Markdown

please explain your code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment