I'm developing a custom theme which uses categories for positioning, all of which begin with an underscore (e.g. _position1). I have an SQL query as below to get a list of these categories (those starting with an underscore).
SELECT name,term_id FROM `wp_terms` WHERE name LIKE '\_%';
How would I go about turning this into a function which returns a list of the category IDs?
The idea being that this list of IDs can be passed to
wp_list_categories() to be excluded e.g. (where get_positional_ids would use the SQL above to return a list of IDs)
<?php $excludeids = get_positional_ids(); $args = array('exclude'=> $excludeids); wp_list_categories($args); ?>
Any ideas on how to do this? Thanks.