If you want to check whether the post id, page id, thumbnail id, or custom post id is same to the number which you want to compare?
Then you land at the right place.
Here:
We have posted simple functions snippets that will help you to match post id then do something with it.
Just follow the below steps:
How to Check Post ID Matches or Not
To compare ID’s we have embedded 4 snippets, use it as per your need.
- Post ID
- Page ID
- Attachment ID
- Custom Post Type ID
Let’s begin with Post ID
Post ID
If you get the ID which is of post’s, Just copy and paste the below code into your file.
Read Also: Get Current Page or Post ID
Page ID
If you get the page ID, then you should copy the below code and paste into your file.
Attachment ID
If you get the Attachment ID and wanna use to do something with the post, then copy the below code and paste it into your file.
Custom Post ID (Any Post Type)
Finally, if you’re unsure of the post type you could check with the global $post object assuming it is correct.
Read also: How to Retrieve the Slug of Current Page
That’s it
Hope the above code snippets helped you in your website project.
Don’t forget to share this to if posts id then do these.