This isn’t possible. The post id is only created during post creation in the database; if you see the post id in the admin editing screen before you hit ‘publish’ or ‘save as draft’ then an autosave created the record for you.
If you ‘fake’ getting the next post id (such as fetching the highest id number from the database and then adding one), there’s a risk of a conflict or a race condition – if any other record is created in between your fetch of the next ID and your creation of a database row, then your id will be invalid and incorrect, or will fail to save.
You need to save your post, then edit the post after saving to add the post id in the place you need it.
Related Posts:
- What is an Endpoint?
- Yahoo! Finance CSV file will not return Dow Jones (^DJI)
- How do you get the API key for Locu?
- WP function/filter for modifying http headers?
- How do I cache (core) API requests?
- WP REST API only returning partial list of users
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- Should I store external API data in my WP database or keep it as a transient?
- How to implement ERP (Enterprise Resource Planning) into WordPress?
- How to get the attached gallery in the rest API?
- WP API : date_query parameter
- WordPress.org Support Forum API
- Authentication/API Questions
- Connect external web app to wordpress
- How to get all posts (in chunks) via XML-RPC?
- How to add a custom parameter to a WP API default route?
- Get more than 10 posts in a specific category with the wordpress api
- Developing Themes with React/Angular
- Authentication for a mobile app connected via wp-rest api?
- curl POST work with user meta but not the custom user meta
- WordPress API – count posts
- how to get nonce using json api
- What is the official way to consume the WordPress API? (api.wordpress.org)
- Create post with REST API in php with file_get_contents
- How to Hit External REST POST API in WordPress? [closed]
- Displaying Content with WP Rest API
- API getting null values with wp_remote_post
- I am trying to use the Theme Customization API but I keep getting an error
- Extending WordPress REST API
- Headless WordPress – Issue with plugin path
- node-wpapi: how to handle authentication?
- Post body not working with wp_remote_post()
- Possible to use wordpress as publishing platform but programmatically inject content?
- How to avoid loading wp-load.php from external php scripts?
- POST request not going through?
- are there any initiatives to work wordpress as microservices?
- Sanitize Disqus API results?
- How can I send edits to my blog programmaticly?
- I want to retrieve all posts of a blog without username & password
- Best Practice for re-using API Data in WordPress?
- WordPress Google Calendar Oath 404
- WordPress as GraphQL client
- Get non-rendered content from WP-API
- How to add custom preview urls for some pages?
- How to save post with different languages and linked them with WPML?
- wordpress “rest_invalid_handler” error
- Calling an API to do authentication / user login
- Add basic authentication of WordPress on any external PHP file?
- Store regex expression in WordPress DB using Options API
- cURL to install theme
- body_class REST field in WP-API
- Authenticating a user with the WP-API V2 in Postman
- Best way to integrate contact us page with wordpress REST API [closed]
- Submit comment via JSON from Android device
- Manage a resource via REST API
- WP List Table in custom post type
- Easiest way to call an External rest API?
- How to send messages when a customer is registered
- Save external API calls in WordPress
- Accessing a 3rd party API – terminology to differentiate between that and publishing an API?
- How to add an endpoint for my custom post type? /wp-json/wp/v2/posts is working but it didn’t in the custom post
- JSON API and notification about registration
- Creating posts from API data, how to identify posts already imported?
- Where to put API Code?
- Use WordPress user database in external php application
- Implement External API into WordPress [closed]
- Integrate WooCommerce to PromoSoftware Rest API
- term_exists returns NULL
- Consuming an external API to publish/post to wordpress
- Set up WP Authentication from External API
- WordPress API Create post content
- Solution for processing lots of data with CRON/API, dealing with memory/timeout issues
- WordPress API causing fatal error
- woocommerce api echo out response
- Limit the number of external API calls per second
- WordPress Theme/Plugin Information API Response to Text and Button
- WordPress API – Getting just post content
- Composer Installed Package with WordPress Rest API Endpoint
- Is there a way to get Google My Business photos on WordPress with the API or other?
- How to use following API with WordPress?
- rest_cannot_create_user
- Implementing URL JSON API Data into Website
- How to use filters/params in wordpress as headless cms api
- How do I filter Child Posts by Parent Post ID for Custom Post types in WordPress REST API response?
- Rest WP_Error always return null
- Using the JSON API via HTTPS and HTTP
- Posting data from Ionic app to WordPress
- WordPress REST API Endpoint (Authors and Categories latest posts)
- Stop Vimeo video with javascript – inside a loop and using a modal window
- Instructure Canvas API with WordPress [closed]
- Why does “if statement” has to “die()”, otherwise wont work?
- REST API And Error Codes – No Message
- Cannot get transient to work on shortcode, Moz API
- XML RPC -> Create User
- Get full page HTML for a non-public WordPress page
- WordPress SMS API integration without plugin
- Zoho subscription API to WordPress [closed]
- Send Order Confirmation automatically to customer’s mobile number
- XMLRPC: How to retrieve possible custom fields for a new post?
- Using WordPress API to mass update posts freezes the server