The get_object_subtype() WordPress PHP function returns the object subtype for a given object ID of a specific type.
Usage
get_object_subtype( $object_type, $object_id );
Parameters
$object_type
(string) – Required. Type of object metadata is for. Accepts ‘post’, ‘comment’, ‘term’, ‘user’, or any other object type with an associated meta table.$object_id
(int) – Required. ID of the object to retrieve its subtype.
More information
See WordPress Developer Resources: get_object_subtype()
Examples
Retrieve post subtype
Retrieve the subtype of a post with the ID 123.
$post_id = 123; $post_subtype = get_object_subtype( 'post', $post_id );
Retrieve comment subtype
Retrieve the subtype of a comment with the ID 456.
$comment_id = 456; $comment_subtype = get_object_subtype( 'comment', $comment_id );
Retrieve term subtype
Retrieve the subtype of a term with the ID 789.
$term_id = 789; $term_subtype = get_object_subtype( 'term', $term_id );
Retrieve user subtype
Retrieve the subtype of a user with the ID 101112.
$user_id = 101112; $user_subtype = get_object_subtype( 'user', $user_id );
Retrieve custom object subtype
Retrieve the subtype of a custom object type ‘my_custom_type’ with the ID 131415.
$custom_object_id = 131415; $custom_object_subtype = get_object_subtype( 'my_custom_type', $custom_object_id );