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-insert-term]

The tag has no usage guidance.

0
votes
2answers
32 views

category not display in word press grammatically

I'm trying to create a new category in the taxonomy.php called 'USSERS'. I have followed few examples online and got till this part. function insert_term( $name,$tax,$parent='' ,$slug='') { $...
0
votes
0answers
18 views

add users to newly created category in single.php file

I need your help with this problem. I have asked this on SO but haven't gotten anything so please don't remove this for that reason. I have a WordPress site and all of it's files/database. The site ...
1
vote
0answers
82 views

Can't create term for product attribute

Please help. I need to create product attribute term after I create a product attribute taxonomy. wc_create_attribute([ 'name' => 'Size', 'slug' => 'size' ]); // This will only work If I ...
0
votes
0answers
113 views

WP_Error on attribute + term insert

I want to add a product attribute (wc_create_attribute) & assigned terms (wp_insert_term) via the functions.php. Example: $args = array( 'name' => "Color", 'slug' => "...
3
votes
1answer
131 views

Not Able to Insert Taxonomy Term Using wp_insert_post()

I have a Custom Post Type called eyeglasses and Custom Taxonomy called models. I also created two terms for taxonomy called M156 and M120. Now I am trying to upload two post for test through ...
1
vote
0answers
131 views

wp_insert_term created and set for first once only

i have two function first is working good to create category and set it in post the problem in the second function is create taxonomy but not set in post !! function autoset_post_category(&$post, ...
0
votes
1answer
952 views

wp_insert_term() doesnt insert a term

My registered custom taxonomy name is ov-category.. There is already existing a parent term called Gender now i want to add a child called Male : $parent_term = term_exists( 'Gender', 'ov-category' )...
1
vote
1answer
853 views

get_tags() return an empty array after added tags with wp_insert_term()

I added some Tags programmatically with wp_insert_term(), and later I call get_tags() to use them, but it returns an empty array, although they are inserted in the database. Here is my code: install....
0
votes
1answer
544 views

Adding predefined terms to a taxonomy

I'm writing a plugin for adding a Custom Post called"Dog". The core of the plugin is strictly based on this one https://github.com/RescueThemes/Rescue-Animal-Custom-Posts I prefer to add predefined ...
0
votes
1answer
344 views

wp_insert_post() does not support variable

I have a problem with the following function as I will pass a variable in wp_insert_term: wp_insert_term( $term, $taxonomy, $args = array() ); It does not work if I do this: wp_insert_term( 'abc', $...
2
votes
1answer
187 views

Allow only 1 instance of each term in each custom taxonomy

I'm looking for a function that restricts the creation of each term to only 1 instance within each custom taxonomy. Each custom taxonomy may have the same term but the term may only occur once in each ...
1
vote
1answer
274 views

Insert terms for custom taxonomy on plugin activation, or each page load (init hook)

Consider a plugin which adds a custom Taxonomy and then fills the taxonomy with a large term hierarchy (tens of hierarchical terms, may become hundreds in specific installations). I understand that ...
1
vote
1answer
295 views

wp_insert_term in a multisite installation

i am creating a theme that creates pages and sets some meta values and ext on theme activation. Everything works great but... I need to insert some terms to misc cpt's in a multisite installation. ...
2
votes
1answer
11k views

Programmatically create product category and add thumbnail in woocommerce

I'm trying to create product-(sub)categories on a WordPress installation. The (sub)categories part is no problem at all, but I can't seem to find a way to add the thumbnail image to the specific ...
0
votes
1answer
522 views

does wp_insert_term link the term to a certain post ID?

I'm using wp_insert_termto add a custom taxonomy like this: wp_insert_term( $_POST['city'], // the term 'property-city', // the taxonomy array( 'description'=> $_POST['...
0
votes
2answers
6k views

WP_insert_term how to insert multiple values as taxonomny term?

I have this script (found online) to import the values of an input form field as a taxonomy term. I got it working, but now I'd like to import/save the values of multiple form fields. Now all it does ...
0
votes
2answers
530 views

INSERTING Data into table with placeholders

I am trying to insert data into a table, getting errors, I have tried messaging the data, but cannot seem to get it to work, can you please help me figure out what I did wrong, please... Here is my ...
1
vote
2answers
7k views

Get category ID after wp_insert_term

I'm using wp_insert_term to create categories, after the category is created I'd like to get its ID: $cat_id = wp_insert_term($name, 'category', array('slug' => $slug) ); ...however when I try ...
4
votes
3answers
835 views

Creating a non-removable taxonomy term

Is there a way, without modifying the core, to create a term for a custom taxonomy programmatically that is non deletable? "Uncategorized" is an example, but in my case, it does not have to be the ...
0
votes
0answers
2k views

When I Use function wp_insert_term() function it gives me Invalid taxonomy object

if(isset($_REQUEST['review_add'])){ $rw_es_name = $_REQUEST['rw_es_name']; $rw_cl_name = $_REQUEST['rw_cl_name']; $rw_cl_email = $_REQUEST['rw_cl_email']; $rw_cl_review = $_REQUEST['rw_cl_review']; $...
0
votes
1answer
977 views

How to add a new child category via an SQL statement?

I have a parent category named "Europe" under which I need to insert some 20+ child categories (France, Italy, Germany, etc.) What is the SQL statement I have to fire to add - for example - France to ...
1
vote
0answers
499 views

import_id parameter for wp_insert_term to create custom ID for category

Is there an option to create a category with a custom ID, like a custom post ID is created using the parameter import_id? $post = array( 'post_title' => 'whatever', 'post_content' => ...
4
votes
2answers
3k views

wp_insert_term doesn't work with custom post type's taxonomy

Here is the problem I am having: I have a custom post type called "weddingguests" This custom post type "weddingguests" has a custom taxonomy, "friendsof", hierarchic I want to programmatically ...
0
votes
1answer
291 views

Calling mysql_query() on another database, assumes WordPress using that database

I'm attempting to import some data from a legacy site into WordPress. First step is terms for taxonomy event_category. Here is my approach: $link = mysql_connect( 'localhost', 'blah', '...
1
vote
4answers
4k views

how is it possible that using wp_insert_category throw a fatal error?

how is it possible that using wp_insert_category throw a fatal error ? I am using it as explained : http://codex.wordpress.org/Function_Reference/wp_insert_category with no change except: $...
1
vote
0answers
632 views

How to sync to custom taxonomies (tag structure)

I have two taxonomies: "Contributers" and "Narrators." I want to sync the terms in these two taxonomies identically, so much so that I wish to be able to click on "Edit Term" and see the information (...
0
votes
1answer
858 views

Adding Child Terms Programatically - No Warning but No dice either

Here's essentially what I'm doing : create_taxonomy_record(array( 'Label', 'tax_parent_slug', 'Label Related', 'this_tax_term_slug')); /* ---> ...
4
votes
1answer
852 views

wp_insert_term is adding a term that has no name

I'm trying to insert a term for a custom taxonomy and a custom post type in Wordpress. The problem I'm running in to is that it successfully inserts a term, and at the right hierarchy level, but the ...
0
votes
1answer
115 views

install.php Custom Taxonomy Term not being added to custom post

So I am stuck on this problem that I am facing when creating a custom taxonomy term in a install.php file. So I am running a WP multisite, and upon new blog creations, I am trying to auto create ...
2
votes
1answer
2k views

Handling duplicates with wp_insert_term()

I'm using wp_insert_term which works quite well Now I want some error handler for when using the same name. $term_id = wp_insert_term( $term, 'wpsc_product_category', $args ); if($term_id) {//my ...
0
votes
1answer
216 views

Problem importing categories and sub-categories

I have an array with the categories and sub-categories I want to import to the "campsite-district-county" taxonomy. My sub-categories are not being inserted with the correct parent. They're being ...
0
votes
1answer
1k views

wp_set_post_terms is assigning only the last of several terms to a post

I have this really simple setup where I loop through an array of actors, and for each actor name I successfully insert a term. Then I use wp_set_post_terms to assign the terms to a post, but this only ...
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. ...
4
votes
1answer
676 views

Insert new term during new post creation

i am currently working on a snippet to insert a new post dynamically (it's a custom post type). During this new post creation i need to insert terms in custom taxonomies associated to the custom post ...
3
votes
1answer
7k views

How to add terms to taxonomy with wp_insert_terms?

I have a huge excel database of locations which I want to add as terms to my current taxonomy. However, I don't know the best way to do this, as inserting manually could take weeks. I have looked at: ...
0
votes
1answer
116 views

merging terms programmatically while maintaining the count

This question is all about finding out the best way to handle merging similar terms. Let's say you have 10 posts tagged as Barack Obama and 20 posts tagged as Obama. and you want to group them all ...
6
votes
1answer
7k views

wp set object terms vs wp set post terms

Examining the following sample code snippet from the WP codex, $post = array( 'ID' => [ <post id> ] //Are you updating an existing post? 'post_author' => [ <user ID> ] //The ...
0
votes
1answer
567 views

wp_insert_term does not insert description. [closed]

I'm using this code. I cannot figure out what the heck is wrong with it? $args = array( 'description',"My Desc", 'slug' => "My Slug", 'parent' => 0 ); $result = ...
0
votes
1answer
782 views

Update custom category fields front-end

Been using this answer -->> (link) to create some custom fields in my categories and it works great ! my only problem is that i have a frontend form that allows creating new categories with an ...