Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55946 new defect (bug)

`post_tag` is not supporting in rest api for custom meta

Reported by: kapilpaul's profile kapilpaul Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9.3
Component: REST API Keywords: reporter-feedback
Focuses: Cc:

Description

Hello,

Recently I have encountered with this issue. I have registered a custom meta for post_tag and category taxonomy. and then I register in the rest api for this field. In rest api for category the custom meta key is showing where in the post_tag rest api it's not showing. I have added proper object types in the register_rest_field. In Tags rest api it is showing if I add the object type as tag. Which is pretty confusing.

Reproduce Steps:

  1. Register Custom Meta for Category and Post Tag (You may add it through cmb2 or ACF)
  2. Enable the custom meta field in rest api.
  3. Update your terms on category and Tags.
  4. Check both the rest api endpoint with the ID/slug

Change History (2)

#1 @lopo
2 years ago

Hi @kapilpaul, are you sure it's not a bug in the plugins you're using?
If I add e.g.

register_meta(
		'term',
		'custom',
		array(
				'single'       => true,
				'type'         => 'string',
				'default'      => 'foobar',
				'show_in_rest' => true,
		)
);

both tags and categories display "meta":{"custom":"foobar"} when queried via REST API.
If I add a custom meta via ACF instead, I can definitely see that missing in tags (but not in categories).

Last edited 2 years ago by lopo (previous) (diff)

#2 @lopo
2 years ago

  • Keywords reporter-feedback added
Note: See TracTickets for help on using tickets.