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

Questions tagged [wp-set-object-terms]

The tag has no usage guidance.

0
votes
0answers
13 views

wp_set_object_terms returns 500 error when called through AJAX function

I created dropdowns on the front-end to allow an admin user to change the custom post taxonomy values. On a save button click it runs an AJAX call to a separate PHP file. $.ajax({ type: 'POST', ...
1
vote
1answer
75 views

Change description on specific WooCommerce product status change

In WooCommerce, when I add couple of code lines to change the product description, on product status change, the website throw an error when submitting (saving). My code: add_action('...
1
vote
2answers
41 views

How to change / delete product short description in Woocommerce

How to change / delete product short description in Woocommerce I use $short_desc = $post->post_excerpt; to read the property but I cant change it with wp_set_object_terms($post->ID, $post-&...
1
vote
1answer
40 views

how to get URL of media uploaded to WordPress via media_handle_sideload()

I'm trying to upload a photo from an URL then set it as the feature image of a product that user is submitting Now I can do the first part of this function the problem is I can't get the new URL of ...
2
votes
1answer
21 views

Append a term to WooCommerce product existing product category terms

I have a form which makes people decide about the sub-categories of their product and the form gets submitted on user post method Im trying to add the parent category to it as well Now I tested ...
0
votes
0answers
17 views

wp_inset_post not adding taxonomy (using wp_set_object_terms)

The following runs through a cron job and successfully creates and publishes the post to a custom category. However, it does not attach a custom taxonomy (ap_job_status) term (ID 3) to the post. $...
0
votes
0answers
40 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
44 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
67 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
90 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
30 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
54 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
107 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
236 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
250 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
450 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
729 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
461 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
128 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
591 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
92 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
347 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
80 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 ...
11
votes
2answers
852 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){ ...
4
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
246 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
664 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
287 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
610 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
86 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
88 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
3k 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
495 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
191 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
2answers
904 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
348 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
717 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
81 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... ...