post_type internal ID?

Question

This may sound like a stupid question, but is there something like an ID associated with the post types (built in or custom) in WordPress?

I’m not interested in the actual post id, but wondering if there’s something like this:

ID         Post type slug
-------------------------
0          post
1          page
2          slider
3          section
...

What I would need would be something like get_post_type_id( $post_type_slug ) so that when I call get_post_type_id( 'slider' ) it would return 2.

The reason: I’m building a post slider shortcode and I need a unique ID that could be in the form of #{$post_type}-slider-{$id}, to avoid duplicates and correctly apply JavaScript.

Thanks!

0
George 3 months 0 Answers 9 views 0

Leave an answer