/**
* 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
- Custom Post Type Data in Sidebar widgets?
- Custom Taxonomy as Dropdown in admin
- Hide custom post type field from author?
- Many to Many Relationship between Two Custom Post Types
- Sorting a query by custom field date
- Creating Photo Gallery System with Custom Post Type
- How to set individual capabilities on a taxonomy? Or how to re-register an existing taxonomy?
- Set post title from two meta fields
- How to sort CPT by custom meta value (date), and return posts month by month
- Trying to save custom post type from frontend partially working
- Custom Taxonomy order by Custom Field
- Custom Post Type: How to display all of same taxonomy?
- List all custom post type posts from a given category?
- Keep display metadata value on backend – Custom Metabox
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Custom Post Type Set Comments ON by default without show METABOX
- Why is my select meta data not saving?
- How do I do this with WordPress? Taxonomies?
- Limit amount of posts made within a custom taxonomy
- Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish
- Custom setting to show or hide field
- Dynamic dropdown select values depending on other custom field value
- Grouping metadatas into one
- Set a CPT slug as a base name for all the taxonomies
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to Output which matched meta_keys were found from custom_type_posts?
- Integrate Custom Post Type Events into Calendar
- How to get a custom field value of a custom post?
- Filter get_cat_id for Custom Post Type
- Query based on custom fields start and end date
- Redirect to another page using contact form 7? [closed]
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- Multiple single templates?
- Custom taxonomy (categories) on custom post type return no results
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Rewrite custom post type with taxonomy
- How do I replace the post title with a custom field?
- Custom Post type loop with ACF not displaying properly
- How to display wp_post by custom field value?
- Sort results without WP_QUERY?
- How can I output WPAlchemy repeating fields meta values in my page template?
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Custom post types category
- Using page title as a link to term archive
- Custom Taxonomy dont save in a frontend form for post a custom post
- Update custom field value
- Should i use custom post type for a custom footer?
- Get List of Terms based on a given term (different taxonomy)
- Custom taxonomy terms as children of multiple custom post types
- Question about link two types of data in wordpress
- Add Tags to a Custom Post Type from a FrontEnd Form
- Get the taxonomy value in the post loop inside the archive page
- Custom post type archive URLs with a single taxonomy
- How to show related posts of category on post within custom posttype
- How to access repeater field of a custom field?
- PHP Warning with Custom Fields
- Custom post types & Pages hierarchy – Error 404
- Listing all custom posts having a specific taxonomy whatever the terms
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- filter rest api post by a acf filed
- How to prepend text to custom field value A, but only if custom field value B matches a certain string?
- Taxonomy template file not working with a taxonomy that contains a slash
- I can not call the categories of custom post type
- Custom post type that lets users create a set of posts?
- Custom Taxonomy page redirecting to 404 page
- Custom Taxonomy is disabled on Edit page
- Override “Parent” input for custom taxonomy
- Delete custom post type metadata without deleting the post in admin area
- Creating multiple CPT posts from one Gravity form
- Function not pulling image or text from custom post type
- Custom Post Type Categories Not Maintaining URL structure any more
- Order Custom Posts by Several Fields
- Best way to structure article and issue relationship for CPT
- Custom Post Type used for FAQs Accordion
- Check if taxonomy is attached to at least one post in a post-type
- Repeatable custom meta select boxes
- How to make an admin create/edit post page to look like taxonomy page?
- Looping taxonomy in taxonomy?
- 404 on Pages for Custom Post Type & Query_Posts
- Custom posts and custom taxonomies for many products and categories?
- Types plugin isn’t compatible with my custom post type
- Show Posts in Vertical Tabs with Scrollbar
- How do I filter a custom post type loop by a field?
- Custom Post type as Taxonomy
- Display div based on Group metabox selection [closed]
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- custom taxonomy not return in the code
- How do I get parameters from the URL?