Get all post types that supports tags

Question

I’m trying to get all the post types that has tags functionality. I searched a lot but couldn’t find a conditional or something for that. I need a way to get post types or post objects for the posts which are taggable.

Here are my current code to get post types:

public function getPostTypes() {
    $excludes = array('attachment');
    $postTypes = get_post_types(
                    array(
                        'public' => true,
                    ),
                    'names'
                 );

    foreach ($excludes as $exclude) {
        unset($postTypes[$exclude]);
    }

    return array_values($postTypes);
}

Thanks!

0
, , Akaki Khujadze 3 months 0 Answers 29 views 0

Leave an answer