Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Get $post->ID from a URL

I know that this is old question, but maybe this will help

url_to_postid( string $url )

WP Code reference

Related Posts:

  1. Query all posts where a meta key does not exist
  2. what is the correct way to compare dates in a WP query_posts meta_query
  3. Get post with multiple meta keys and value
  4. Admin Area Custom Type Search By Meta Fields Without Title & Content
  5. Echo all meta keys of a custom-post TYPE
  6. Post metadata deletes itself
  7. Custom Post Type: Set post_title equal to a custom post type field
  8. I can’t set meta_key in my custom post type query
  9. How can I include meta box content when searching?
  10. update a post meta from a single table cell TablePress
  11. Custom Meta Boxes – Nonce Issue – Move to trash issue
  12. Automatically adding meta data to posts or multiple query help
  13. Trigger “unsaved changes” dialog for custom post meta changes
  14. Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
  15. Displaying custom posts only if custom meta box’s date is not expired
  16. Displaying Metabox value (custom post type taxonomy)
  17. How do I sort a custom post type admin column using two meta keys?
  18. How can I display my custom metaboxes on a custom post template?
  19. get_post_meta is returning image id
  20. Custom Post Type, Saving Multiple Checkboxes
  21. Create a random unique 6 digit number as custom field for custom post type
  22. Export entries and multiple custom field meta to .csv?
  23. how to interconnect custom post types?
  24. orderby in custom WP Query does not work
  25. Insert post metadata for all posts in CPT at once if metadata no existent
  26. Display custom post type from dynamic custom field
  27. Populate dropdown from one custom post type inside another custom post type
  28. Notice: Undefined index: error and understanding wordpress
  29. Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
  30. Get posts between custom dates
  31. Deleting Custom Posts & Meta Data on Uninstall
  32. How do I create an archive page as a including metadata?
  33. Two Custom Post Types Many to Many Relationship
  34. how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
  35. post meta parameter in post custom-post-type endpoint with restapi
  36. Update postmeta Parent when post_status child change
  37. Update database from Quick Edit according to Checkbox state of Custom Post Type
  38. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  39. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  40. Dynamic Custom Fields
  41. Show Custom Post Type meta boxes only on Page Edit
  42. Custom filter function not working with Custom post type
  43. Remove Post Custom Meta Box
  44. Meta Data for Custom Post Type not saving
  45. Using preg_replace to filter custom textarea
  46. Check if post with same meta value exists
  47. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  48. Archieve.php not loading for custom post type
  49. Displaying a div from an assigned meta_value when on a page
  50. Create Array from custom post type to display a slider
  51. Values from meta-box not on $_POST
  52. Returning a custom content types with meta values
  53. Custom post type suddenly stoped working after WordPress 5 update
  54. copy images from custom field to another custom field
  55. How to show custom field on specific custom post type posts only when filled
  56. Cannot obtain custom meta information
  57. is_main_query() never called on WP 4.4
  58. How can I output WPAlchemy repeating fields meta values in my page template?
  59. Save Metabox Custom Field Value
  60. Meta box data not saving
  61. How can I get some of a posts meta data whilst it is still inserting?
  62. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  63. best way to use custom taxonomy, post type and meta in a job system
  64. Empty meta-box returns publishdate if no value is set?
  65. Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
  66. Building tags and archive using meta from custom post type
  67. How to order custom posts by one of the custom fields value, ‘date’?
  68. Custom Meta Box with variable number of fields
  69. WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
  70. Custom Post Type meta data getting deleted on bulk editing taxonomies
  71. How to create review point system for CPTs (many-to-many relationship)
  72. After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
  73. How can I write a function that would update any missing specific post metadata?
  74. SELECT custom post type and its meta in SQL
  75. Custom attachment function not working in v5.4.2?
  76. How to return/export only data showing on screen in custom post type view all screen
  77. Use WP_query to match post types based on custom field values
  78. How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
  79. Custom Function to redirect singular post if specific meta field is empty
  80. Stored meta from attachment, video length?
  81. Saving Child Terms on front end not setting parent
  82. Custom post type: “transition_post_status” action get title and other fields
  83. update a posts of other custom post type
  84. How do I extract the contents of a CPT’s custom field for all posts?
  85. How to get post meta for custom post type and taxonomy
  86. Delete custom post type metadata without deleting the post in admin area
  87. Order by post meta value gets random results
  88. meta query always fails even if data is correct
  89. How to create content automatically when a post is published?
  90. Rich Custom Field for Custom Post type not saving
  91. Add auto increment value to custom meta
  92. Custom post type submenu sorted by specific meta_key & meta_value
  93. Return only custom post types for the page, not all
  94. Retrieve post data via WPDB class
  95. Create action running on trashed_post hook to modify post_meta value
  96. Post AND page parameter for WP function
  97. Custom Post Type meta value is being saved in array, instead of just the string (as value)
  98. Automatically add custom taxonomy when meta value gets to a set number or beyond
  99. Check for custom field value in different post type than current one and do something
  100. rest_api_init is not getting invoked inside a Class
Categories custom-post-types Tags custom-post-types, post-meta
WordPress tabindex Order
content editor format style tags

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress