Get current category (taxonomy) children and prepare them for options element.

Get current category (taxonomy) children and prepare them for options element.

Today I will share something that I use often. Getting the children of the current queried category or taxonomy and making from them an array containing slugs and titles (names).



This PHP function is very helpful when creating a <select> dropdown for subcategories filter for example.

Usage example

 

Autor: Dimitar Radev | Modified: October 10, 2018 at 3:24 am | Category: WordPress


Leave a Reply

Your email address will not be published. Required fields are marked *

Advertising

Related posts

How to get the_content with all HTML tags inside functions.php?

To get the post or page content inside WordPress functions.php with all the HTML tags you need to use the_content filter. This method …

How to Fix PHP 7.2 “Warning: count()” on get_the_content() or the_content()

Looking to fix this “Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/post-template.php on line 284” or …