/**
* Programmatically assign taxonomy term by custom fields
*
* @param int $post_id
*/
function rd_assign_taxonomies($post_id) {
if (get_post_type($post_id) == 'vegetables') {
$terms = array();
// Here we'd check to see if the post has the specific fields, and if so add the IDs or slugs of the taxonomy terms to the $terms array
// The exact details will depend on how the checkboxes were implemented, for example as native postmeta or ACF fields
wp_set_object_terms( $post_id, $terms, 'seasons', false );
}
}
add_action('save_post', 'rd_assign_taxonomies');
Related Posts:
- Custom Post Type – Taxonomy Dropdown Menu?
- Custom Taxonomy Template Post List with Sort Order
- Custom Post Type with Custom Title
- Add Taxonomy Values Within a Custom Post Type RSS Feed
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- Targeting categories in custom fields
- Get post-meta value of all custom-posts – lowest to highest year-count?
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- wp_set_object_terms creates taxonomies but does not add custom posts to it
- Query Distinct Taxonomies of Custom Post Type
- How to get all taxonomies of a post type?
- Renaming Custom Post Types and Taxonomies
- How to Add Custom Fields to a Custom Post Type?
- Display custom post type and custom fields within a Bootstrap Carousel
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Display Custom Post Type Fields
- Taxonomy page returns 404 page not found
- It is possible to get a list of post types asociated to a taxonomy?
- How to get the parent’s taxonomy?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Same base slug for CPT post and CPT taxonomy terms
- wp_insert_post custom taxonomy
- Display taxonomy term only if there’s a value
- Post Link Filter Help [closed]
- Bulk edit custom excerpt text in WordPress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Getting a “Changes you made will be lost” dialog prompt on a custom post type page
- Frontend posting – everything saves other than checkboxes?
- Search Custom Post Type Custom Fields
- Automatically populate a hierarchical taxonomy from a custom field
- WordPress posts with multiple fields
- List of Posts in a Custom Field
- Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta
- Tag page with Custom Post Types not returning any posts
- CPT Group by Date metabox Value
- Replace text in post from cvs
- Admin search ACF relationship
- Give a permalink to Custom Post Types without title
- Cannot add custom field to “orderby” parameter in Rest API
- Trash / Draft a WordPress custom post after custom date field expires
- Posting to a Custom Post Type from front end – user generated content
- Custom Meta Field – Remove comma from string with str_replace
- How to conditionally redirect to the post from a taxonomy page?
- Filter custom post types by a field value
- First custom field value (out of several) displayed twice after query
- Displaying custom field according to date
- Taxonomy in URL
- Custom fields for custom post type
- Warning: Invalid argument supplied for foreach() [closed]
- Add additional field to custom post_type
- How to Set Taxonomy Object Description?
- Variable not working in WP_Query
- Alphabetically sort a taxonomy.php template by post title
- How to conditionally add Custom Post Type to Front Page
- Show Taxonomies with admin area for custom post type?
- Displaying custom fields for custom post type generate with Custom Post Type UI Plugin
- Best way to create a search for custom post type by custom field values
- Copy/Move selected taxonomy terms to another taxonomy for posts
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- Display Posts Query with IF function
- Excerpt length: get first paragraph
- Custom PT, Taxonomys and wordpress query
- Sort Archive by Taxonomy
- How can i loop through custom post type according to custom meta field?
- How to use get_post_custom_values to return the value of an array
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Page that lists publications by classifying them by taxonomy
- Filtering posts based on three taxonomies
- Display category filters for custom post type when category is shared by multiple post types
- How to order taxonomy terms by most recent post?
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- editing shortcode for custom post type within a plugin
- Sort custom post archives by a meta value from a different custom post type?
- List all posts associated under custom taxonomy
- Custom post type category link + add to menu
- Use WP Title instead of custom field to call
- Custom taxonomy template for custom fields loop [closed]
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Add more custom fields when creating a new custom post type
- Taxonomy and Custom Post type with Collpase
- How do I display specific custom posts, and how do I edit a post’s singular page?
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- Amend posts using wp_insert_post
- Custom Fields as Post Type Options
- Listing Custom Post Post from certain category
- Custom Post Type parent slug as menu item
- How to get past and upcoming post by defining date in custom field?
- display some fields in custom post backend
- Archive templates based on taxonomies
- How to display Multi Checkbos select Custom Field on the post?
- Display posts order by custom post in a dropdown menu
- Query recent posts by author
- Textarea type on one field custom add_meta_box?
- Adding a custom “Add Custom Field” button to Custom Meta boxes
- Single and Archive Pages with Custom Post Type
- How to change order of custom post types. I want Featured post to come first