I have taken over a site from someone. He has a list of businesses on the site, each one has a URL, saved as a field:
$iframe_url = get_field(‘manufacturer_url’);
It seems he used to manage this URL on a custom post-type page, but the actual field to edit the URL has disappeared – maybe in some recent WordPress update.
I have made sure on the edit page, all the elements are checked off on the ‘screen options’ tab. But i still cannot see where this field is, where i can change the URL. Any ideas?
Using Version 5.8.7 of the plugin WP version: WordPress 5.1.4 running Chameleon-Child theme.
I have taken over a site from someone. He has a list of businesses on the site, each one has a URL, saved as a field:
$iframe_url = get_field(‘manufacturer_url’);
It seems he used to manage this URL on a custom post-type page, but the actual field to edit the URL has disappeared – maybe in some recent WordPress update.
I have made sure on the edit page, all the elements are checked off on the ‘screen options’ tab. But i still cannot see where this field is, where i can change the URL. Any ideas?
Using Version 5.8.7 of the plugin WP version: WordPress 5.1.4 running Chameleon-Child theme.
Share Improve this question asked Feb 6, 2020 at 20:51 kneidelskneidels 2751 gold badge6 silver badges14 bronze badges 2- Are you using the Block Editor? Some old meta fields need to be explicitly set to show in the REST API so they work with the new Editor. – WebElaine Commented Feb 6, 2020 at 22:12
- @WebElaine - yes, I'm using the block editor. Can you explain what should be done? Thanks – kneidels Commented Feb 8, 2020 at 21:01
2 Answers
Reset to default 0To expose a postmeta field in the Block Editor, you need to register it and enable it to show in the REST API.
With your field being named "manufacturer_url" you would use something like this:
<?php
// Use "init" hook
add_action('init', 'wpse_register_mfr_postmeta');
function wpse_register_mfr_postmeta() {
// Make sure to set your CPT slug as the first argument
register_post_meta('mycptslug', 'manufacturer_url', array(
// Critical part: show in REST API
'show_in_rest' => true,
// You're probably storing a string but double-check first:
'type' => 'string',
// If you only allow 1 manufacturer_url per post, use this
'single' => true
));
}
?>
You can place this in a custom or child theme's "functions.php" file, or as its own custom plugin just by adding a comment with "Plugin Name" at the top. (Since you probably don't want the data disappearing if you switch themes, setting it up as a plugin is likely the best approach.)
Followup for any future questioner.
It seems like the Field Group of ACF had been deleted. As soon as i created a new group and field named 'manufacturer_url'
the fields all became accessible again.
Thank you.