Is there a way to add a hidden custom field to a CPT?
We have a news_category custom field setup that is used on our News CPT. It has various options (Announcements, Press Releases, etc). We would like to reusue this custom field on the Posts CPT but have it hidden and have the News value always submitted for a blog post.
We need this so we can do some filtering between the two CPTs.
Hi,
Thank you for contacting us and I'd be happy to assist.
Something like this can be achieved if the post is being created/edited through the front-end Toolset forms, but not through the default post editor in the admin area.
You can add a new custom field group that is common to 'News' and 'Posts' CPTs and include the 'news_category' field into that field group, so that is available for both CPTs.
Additional note: If the goal is to filter the posts by 'news_category', it would be more efficient to use a common custom taxonomy instead of a custom field. Taxonomies are better optimized for filtering and offer better performance.
regards,
Waqar