The following should do what you need:
add_action ('save_post_site-members', 'add_term') ;
function
add_term ($post_id)
{
if (defined ('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return ;
}
$meta_key = 'aab-ew-select-visible' ;
$tax = 'test-all-members-cpt-tax' ;
$term_slug = 'test-all-members-ew-tax' ;
$meta_value = isset ($_REQUEST[$meta_key]) ? $_REQUEST[$meta_key] : '' ;
if ('display' == $meta_value) {
$term = get_term_by ('slug', $term_slug, $tax) ;
if ($term) {
wp_set_object_terms ($post_id, $term->term_id, $tax, true) ;
}
}
return ;
}
Related Posts:
- Custom Post Type Data in Sidebar widgets?
- Hide custom post type field from author?
- Many to Many Relationship between Two Custom Post Types
- Sorting a query by custom field date
- echo value from ‘select’ field type into page template using cmb2?
- wordpress plugin error handling
- Creating Photo Gallery System with Custom Post Type
- Set post title from two meta fields
- Rewrite custom post type url’s adding meta box values
- How to sort CPT by custom meta value (date), and return posts month by month
- How to solve suspected memory issue in custom WordPress loop?
- Trying to save custom post type from frontend partially working
- Custom Taxonomy order by Custom Field
- Comparing timestamps in meta query doesn’t work
- Stopping WordPress from Auto Generating Image Files for Sizes
- Is there any performance consideration when using Custom Post Types?
- Custom Post Type Navigation on Custom Field
- how to interconnect custom post types?
- WP All Import – Using Xpath to set a select value
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Automatically update custom field in all posts of a custom post type
- Keep display metadata value on backend – Custom Metabox
- search also in taxonomy, tags and custom fields
- Filter custom posts using auto populated dropdown selectors
- Querying Two Custom Post Types with OR Not Working
- How can I get the number of custom post type posts that have a specific attachment image set?
- Bulk Update Custom Fields for Custom Post Types
- Add custom field to Posts and sort by it
- Two Custom Post Types Many to Many Relationship
- Including metaboxes from custom post types in global search — continued
- Show image gallery from a custom field
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- filter custom post in rest api with custom function
- Custom Fields for Custom Post [closed]
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Adding Page Templates to post but it ignored it
- Is there any way to add a “custom field” to the CPT archive page?
- How to Output which matched meta_keys were found from custom_type_posts?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- Query based on custom fields start and end date
- How can meta boxes be added to “unknown” custom posts?
- Custom “radio button meta box” not saving correctly
- Check if post with same meta value exists
- Custom posts type for individual pages?
- custom post data – how to
- 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?
- WP Query ‘posts_per_page’
- Custom Post Type Metadata Not Saving
- Editor / Add Media: Is it possible to only allow galleries?
- What do the numbers mean at the end of add_action(‘save_post’)…?
- A meta box (in a custom post type) with two different type of fields
- Many to many to many custom post relationships
- copy images from custom field to another custom field
- Custom Query: If One Post Object Field Value Is The Same As Another
- How to migrate Custom Field Template to a WordPress Multisite
- How do I replace the post title with a custom field?
- Sum and count of custom field values
- Cannot obtain custom meta information
- How to use a specific custom field in a custom post type as slug
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- How to hide a custom field from admin?
- Adding an extra parameter [string] to my posts’ permalink?
- Add Extra Category Field to CPT Categories
- Cache issue with WP_Query and custom field filtering
- Empty meta-box returns publishdate if no value is set?
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- Alike Shortcode using in Custom Shortcode
- Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- Custom Metabox Info Not Saving
- How to access repeater field of a custom field?
- Post Filtered by Custom Field Value
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Meta_Query refuses to return results
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Search facility with directories
- How do I extract the contents of a CPT’s custom field for all posts?
- Delete custom post type metadata without deleting the post in admin area
- How to delete comma from the end of results? [closed]
- Publish post and create additional posts with same content
- Creating multiple CPT posts from one Gravity form
- Converting a checkbox filter for custom fields to a dropdown
- Function not pulling image or text from custom post type
- Order Custom Posts by Several Fields
- Custom field totals
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Repeatable custom meta select boxes
- 404 on Pages for Custom Post Type & Query_Posts
- How to show animal lineage/pedigree in WordPress?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- 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]
- Check for custom field value in different post type than current one and do something
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Update Custom Field daily within 7days