Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [wp-set-object-terms]

The tag has no usage guidance.

0
votes
0answers
29 views

wp_set_object_terms() to update a post taxonomy value

I need to update the taxonomy value of my post, so i tried with wp_set_object_terms() but it creates me a new value instead. My taxonomy : 'expediteur' The taxonomy value ID to be attached: 69 ...
0
votes
0answers
30 views

Wordpress wp_set_object_terms() not working fully with WooCommerce

My custom taxonomy (WooCommerce attribute) already exists and I am using the following to add a new term to the taxonomy and associate it with my WooCommerce product: wp_set_object_terms($product_id, ...
0
votes
1answer
42 views

wp_set_post_terms not updating with WP Cron Event

I have a jobs board custom post type (job_listings) with a taxonomy (cvl_job_status) attached with various tags assigned, namely; Live, Filled and Expired. Each job post has a custom field (...
0
votes
1answer
73 views

How to return newly added terms when using wp_set_object_terms

I am using wp_set_object_terms to add terms (attributes) to our WooCommerce products: wp_set_object_terms($id, array($migrate_case), 'pa_case'); This gives us the advantage (instead of using ...
0
votes
1answer
28 views

How best to store data (URLs and IDs) extracted from posts and pages using custom taxonomies

I want to store metadata extracted from post/page content: IDs of other posts/pages on the same blog linked within the content of each post/page certain external URLs contained within the content of ...
0
votes
0answers
52 views

setting a custom post type taxonomy term by code

I have a set of radio buttons on my metabox which looks like <div class="panel-body"> <label class="radios"> <input type="radio" name="r3" value="15"> No</label> <...
0
votes
1answer
95 views

Saving Child Terms on front end not setting parent

I recently had a issue where I was trying to save the child terms on a front end post form. ORIGINAL POST AND CODE I thought I had it good to go but now I just realize it's not setting the parent ...
0
votes
1answer
222 views

wp_set_post_terms struggle :(

I have trying to find that one without luck for a while therefore I come to you. when I try to insert a term as custom taxonomy it doesn t work completely. If I write this wp_set_object_terms( $...
0
votes
1answer
239 views

Dynamically set taxonomy term and show admin notice on post save

I have a taxonomy of "date" listing all months of the year. And I have a custom field of "start_date". I would like to update the 'date' taxonomy dynamically so the user doesnt need to click both when ...
0
votes
1answer
412 views

How to relate a user object to taxonomy term?

I am attempting to import several users, who each should have a connection with a term in a taxonomy named "firm" - but I don't know how to make the connection... Background: FYI, I have already ...
1
vote
1answer
1k views

Update post terms with custom taxonomy

I have multiple customs post types: CPT1 = "bike", CPT2 = "car" They share a common custom taxonomy "colors" (with terms : "blue", "red" ). They also have their own taxonomy with terms like :...
0
votes
1answer
645 views

wp_set_object_terms NOT working on CPT, but wp_set_post_terms does

I have a function that runs with user input variable (comma separated numeric string) to update the terms (by id) in a custom taxonomy on a custom post type. Even though the docs say I should use ...
0
votes
1answer
442 views

wp_set_object_terms not accepting variable array

I am trying to use the following command: wp_set_object_terms( $myID, $myissuearray, 'my_issues', true ); But for some reason, it won't accept my variable array. That array, $myissuearray, using ...
1
vote
0answers
124 views

Custom Post, set object Taxonomy terms in plugin

I have some problem with taxonomy and custom post saved from form in front-end. I have custom post with attached taxonomy to it, and three terms in this taxonomy. Taxonomy was defined in ...
0
votes
1answer
563 views

set terms to category and subcategory

I am developing a import plug in where I would upload a text file which contain all sorts of data about vehicle and that would insert that data in custom post type vehicle. Now I am having problem ...
0
votes
0answers
87 views

set_object_terms for custom taxonomy in custom post type - not working

All I want is to set a custom posts taxonomy. Here is the taxonomy "lostitem" I registered for the custom post type "verloren" function create_taxonomies(){ $labels = array( 'name' => _x('Lost ...
1
vote
1answer
322 views

Limit number of terms that a custom taxonomy can save per custom post type

I want to limit custom taxonomy created per post to be limited to 1. So, only 1 tag, or 1 category added to a custom post type. I looked into wp_set_object_terms and unfortunately, action/filters are ...
0
votes
1answer
80 views

issue with saving custom metaboxes fields

I have a post_type named room_type and a taxonomy room_facility. Between them I want a relationship. Furthermore I would like to add a value for each relationship room_type and room_facility. So the ...
0
votes
1answer
79 views

Wordpress get all post with like in terms [duplicate]

I have a wordpress site, which has post and custom taxonomy. I want all post of a particular taxonomy with like query. For example: Table: wp_post post_id 100 Table: term_relationship post_id ...
12
votes
2answers
812 views

Is there a downside of using wp_defer_term_counting?

I have a WordPress database with over 2 million posts. Whenever I insert a new post I have to call wp_set_object_terms which takes over two seconds to execute. I came across this post that recommends ...
-1
votes
1answer
76 views

wp_set_object_terms() without accents

How can I remove accents from term names before saving them to the database? // populate term if( empty ($d)) { } else { foreach ($d as $key=>$name){ ...
5
votes
2answers
1k views

Elegant way to add parent categories?

Is there any more elegant way to automatically add the parent categories through PHP (not JavaScript) upon registering categories for a post from some custom page? I Add the categories checked with ...
1
vote
0answers
237 views

Extend Walker Class for 2 checkbox taxonomy selection?

I am working on an add-content front end form (posts in this case). I am able to display, and add, categories and taxonomies to posts correctly with the following: <div class="checkbox"> &...
1
vote
1answer
655 views

Updating / Saving items generated by wp_terms_checklist on frontend

I'm displaying a list of custom taxonomies from a custom post type on a frontend page which shows any items that the user has previously selected as checked. I have got it displaying correctly, but I ...
1
vote
1answer
281 views

setting taxonomy term to bulk posts using ids

Is there any way to insert a taxonomy term to different posts whose ids are known in bulk. For example, suppose we have custom post types with ids 4522, 4524, 4526, 4528 and 4530; how can I insert a ...
-1
votes
1answer
2k views

Default post_tag for custom post type

Is there a way to set a default post_tag to all posts within a custom post type. I would like all my posts from a custom posts type assigned to one tag displayed in the wp_tag_cloud. Is there a way ...
4
votes
1answer
1k views

wp_set_object_terms and arrays

I need to add a category to about 2500 posts, and either need to use an SQL query or wp_set_object_terms with PHP. I'm looking at wp_set_object_terms so I can add a category and not impact the ...
2
votes
1answer
1k views

What are terms and taxonomy, how they related to post and how these three are stored in database?

I want to understand terms and taxonomy in WordPress. My questions: What are the terms and taxonomy in wordpress? How terms and taxonomy relates to post and how post, terms, taxonomy are stored in ...
3
votes
1answer
595 views

Send an email when custom post type category is changed

This is the first time I've attempted to write an action hook. My CPT has 4 categories. I'm trying to make WP automatically sends an email notification when the category is changed. By change I ...
1
vote
2answers
9k views

Programmatically add terms to custom post types

What I want to do is assign a hierarchical term to a custom post type: function create_frontles_posts() { $x = 1; do { $post_id = wp_insert_post(array( 'comment_status' => '...
3
votes
1answer
10k views

wp_set_object_terms() is not replacing term, but creating a new one

From a custom Submenu Page if I use a hard code like: $post_id = 111; $flightCategory = array( 25 ); wp_set_object_terms( $post_id, $flightCategory, 'flight_categories' ); And refresh the page, it ...
0
votes
1answer
83 views

Add post tag without post id

How can I add a new Tag without an post-id? wp_set_post_tags() needs a Post-Id, but a client want import Post-Tags without assignment to a post (for choosing later into the posts).
0
votes
1answer
87 views

WordPress object for comments frame [closed]

For two days I have tried to make this code work. I want to add a comment frame in single.php. I got this code to put it in the single page's template: <script type="text/javascript" charset="utf­-...
0
votes
3answers
2k views

What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?

I need to delete some postmeta when deleting taxonomy terms from the backend. Before deleting the term, I need to retrieve the postmeta's meka_key and the term id that is going to be deleted. Use the ...
-1
votes
1answer
475 views

How can I get the term_id from the action hook 'set_object_terms'?

I have the following code and I want to use the term_id inside that function. I aware that the variable $terms contains the term; however, I do not know how to get the term id from it. add_action('...
0
votes
1answer
187 views

Set unique term_id from custom meta keys

I have a function to set a custom meta keys values to a taxanomy, term. $category20 = $fields['field_52dd3aa1d6bc0']; // gps wp_delete_object_term_relationships( $post_id, 'gps' ); ...
0
votes
1answer
872 views

Removing a taxonomy term

There is a Wordpress function called wp_remove_object_terms that unfortunatly doesn't seem to work. I am trying to achieve the same ends using the following $post_terms = wp_get_object_terms( $...
0
votes
1answer
321 views

How to add terms (without deleting others)

I have a form on my site that allows signed in users tag products from the front-end of the site in a basic form. I am using Woocommerce as the commerce platform. Woocommerce uses Custom Post Types ...
1
vote
1answer
1k views

Programmatically add posts add and assign postmeta and assign terms

I have thousands of WooCommerce products that need to be inserted into the database. For some reasons I can't use the csv import plugin or any other 3rd party solution and this has to be done manually ...
0
votes
1answer
707 views

Trying to use wp_set_object_terms while supplying an array for both term id, and texonomies

I'm trying to use wp_set_object_terms ref : http://codex.wordpress.org/Function_Reference/wp_set_object_terms while passing array for both the terms and taxonomy for some reason i keep getting : ...
0
votes
1answer
80 views

Pass custom value to custom taxonomy

I'm trying to pass a custom field value into a custom taxamony whenever I publish a post. Everything works fine except the meta value part. I can only pass strings. In the codex it says that ...
2
votes
1answer
1k views

Automatically assign taxonomy term if custom meta value exists

I currently have a custom meta field for adding a video url to the post. I'd like for the existing taxonomy term "video" to be automatically assigned to the post upon saving if the meta field has any ...
2
votes
1answer
8k views

Wp set post terms not work

My code is not working, it does not add the taxonomy add_action('init', 'post_test', 10); function post_test() { $empty = get_page_by_title('Produto teste', OBJECT, 'produtos'); if(empty($...
0
votes
2answers
1k views

Custom Taxonomy dont save in a frontend form for post a custom post

I have a Dropdown Categories .. <?php wp_dropdown_categories('taxonomy=faenas_combenef_category&hide_empty=0&orderby=name&order=asc&name=location') ?> And my post Process... ...
0
votes
1answer
378 views

Custom terms inserting as single string with commas, not separated

I have a front end form, one of the inputs asks for a comma separated list of keywords which should each end up being a custom term, I just saw in the backend the terms are entered as single string ...
0
votes
1answer
3k views

How to set hierarchical terms to a post using wp_set_object_terms

I have a hierarchical custom taxonomy called "locations". The parent categories are country names, the child categories are the territories under the country. How can i attach these terms to a post ...
3
votes
1answer
5k views

How can I add programmatically custom taxonomy terms to a custom type post when saving posts?

Scenario: there is a 'Recommended Books' section on the website which uses the 'book' custom post type and the 'author' custom taxonomy. I'm using Amazon Product Advertising API for retrieving book ...
0
votes
1answer
76 views

Modify functions.php to add a term 'uses-theme' set to theme name on post save

I need to automatically (without anything visible to the user in the UI and without user intervention) 'mark' a post in a sub-blog with the theme it was set to when the user posted. As I understand ...
2
votes
1answer
1k views

Programmatically insert hierarchical terms & set terms for post causes glitch? [duplicate]

I am inserting an array of terms into my custom taxonomy programmatically. Some terms have parents/children. After each term has been entered, I then insert an array of posts into my custom post type. ...
1
vote
1answer
532 views

Do I have to set parent when set post term?

When save a term which is a child term, if I don't provide specific parent id, will WP make this term's parent 0 ?