My question is, is there a similar selector for when you don’t know the post type of a post beforehand?
No, at the current time of writing there is not.
The fundamental problem is that the REST API doesn’t provide a generic mechanism for getting a post type given a post ID. You can retrieve a post and it will say post
but to do this you need to know the type in advance to hit the correct URL.
Since the entity Record API relies on these endpoints, there technically are no post IDs. There’s a page record with an ID, or a post record with an ID, etc
So if you want to do this properly, you need to either save the post type, restrict the types allowed for that meta field, or loop through the different entity types to see which ones return a 404 and which one doesn’t.
Related Posts:
- How to update a meta field of type array in Gutenberg
- How to save a ToggleControl value in a meta field?
- Add new image block, set default class name and update it using Javascript
- Validating Custom Meta Box Values & Required Fields
- Is there a way to set default custom fields when creating a post?
- Set default image link target in Gutenberg image block
- Is there any action filter/hook for validating a custom field before publishing the post?
- Add subtitle to Woocommerce product title
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Gutenberg add a custom metabox to default blocks
- Using TinyMce with textareas in meta boxes on custom post types
- Add metabox to document tab in gutenberg
- Extend core block in Gutenberg
- Unable to get Preview of Uploaded image within a Custom Meta box
- Hooking a callback into the code within a Gutenberg block
- extend Meta Box / Document Panel
- Get updated meta data after save_post hook
- Gutenberg Custom Block
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- Check before publishing, if already exist post with current custom field value
- HTML / Javascript in custom field textarea?
- post meta data clearing on autosave
- Store JSON in a custom field
- Display info from custom fields in all images’ HTML
- Using custom fields in a filter hook
- What do the args for Gutenberg subpackage “hooks” function “doAction” mean?
- Update meta values with AJAX
- Why does this Quick Edit checkbox save the value only when unchecked?
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- Use useSelect/useDispatch instead of withSelect/withDispatch
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Registration and Profile custom field
- Custom Meta Box not Saving in Posts with Gutenberg Editor
- Print custom field in Query Loop block
- Unsaved changes in metabox inputs not detected in the block editor
- Possible to add a meta field for css attribute to the editor Advanced panel?
- Send email with custom fields after new draft is saved or new post published
- Manipulate javascript code from custom made admin page menu
- jQuery – Automatic event trigger does not **really** check my form
- Populate Javascript code with value from WordPress Custom Field?
- Hook after meta created
- useSelect second parameter
- Can’t save custom field on registration page
- Get terms of a taxonomy using useSelect
- Looping inside block return
- Update post meta custom field using block editor
- Best Way to get facebook share count and update using wp_schedule_event or any other method
- No result update a custom field using wp_schedule_event
- Using Custom Fields to Trigger Specific Actions on Saving a Post?
- Meta field bulk editing no longer working in WP 6.0 [closed]
- Type character in name and make it invisble
- how to enable custom fields in the Gutenberg post editor
- How to set up page fields with gutenberg instead of ACF
- Refresh Gutenberg with JS for it show updated post
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Gutenberg add a custom metabox to default blocks
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Issue migrating a checkbox-type meta field to the block editor
- WordPress Blocks, setAttributes not saving
- Why isn’t update_post_meta saving?
- Can’t set custom meta fields for a post
- Custom meta POST request fired twice when updating a post in Gutenberg
- change attachment custom field onChange event
- Custom field in external Javascript
- Change event firing in wordpress
- Incorrect data after modifying post using backlink from wp_die
- How can I duplicate “Add Custom Field” with just JavaScript?
- How to automatically create a custom field when a post is published?
- Add custom fields to specific menus
- Custom Fields after update to WordPress 6
- How can I copy value from dropdown once I select it to text area as text?
- Set new url from custom post field
- Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]
- Modal pop-up HTML code works on other sites or HTML viewers but not in the custom HTML block within a wordpress page?
- How to use useSelect to retrieve the currently default fontFamily?
- Block Editor – Meta values not saved, meta changes to empty array on update
- useSelect() plus resolver result is serving cached data incorrectly
- What is the best way to get a different post’s custom field/postmeta with js?
- Custom Search, MySql Query Gone Wrong?
- Block pattern conflict with custom block
- How To Apply Different Styles To All Blocks Based on Post Meta Value?
- Why wp_ajax hooks doesn’t work?
- Custom filename when pasting an image from clipboard
- Use custom field value as href
- add_post_meta insert null value into Database
- Make Custom Fields Public in JSON – API
- Pagination not displaying correct number of pages
- Update field name without losing the value
- get adjacent post by meta key and meta value
- Custom registration form and custom field
- Advenced custom fields auto fill problem
- Cannot Hide Google Map if custom field is blank
- Display custom field outside the loop
- Adding custom field to an array
- How to implement jquery-ui autocomplete into custom fields?
- unlink() doesn’t delete the uploaded file
- Get single image from custom fields made with WCK custom fields creator
- Post count by meta_key meta_value [closed]
- How do i output images from URL’s added to the same custom field key
- Change post status by custom fields