php - Doing wp_set_object_terms on a wordpress post causes duplicate posts to be made? -


I am creating a WordPress post through the following code:

  $ data = Array (); $ Data ['post_ title'] = $ this- & gt; Title; $ Data ['post_content'] = $ this- & gt; Desc; $ Data ['post_status'] = 'published'; $ Data ['post_type'] = 'product'; $ This- & gt; Id = wp_insert_post ($ data); add_post_meta ($ --- id, "foo", $ this-> foo); add_post_meta ($ this-> ID, "bar", $ this-> bar);   

After doing this, I then try to set the classification conditions for the post.

I have a classification that is called "fu" and I have 10-12 words before making a post in the wp_terms table, I have retrieved the word _id of that term I want to use, and I already know that classification is foo, I do the following:

  // The word wp_setms table already contains wp_set_object_terms ($ the-> id, $ this-> termId, "foo");   

When I do this, sometimes, for some posts, a duplicate post is created randomly. It is done within the code of WordPress, and is not done by my code.

Any thoughts that I am doing wrong?

Apparently this error was occurring because my plugin was all about init Hooking on the hook It seems that by setting conditions, sometimes a new request starts, which would re-start the init operation twice, to which my plugins had to run again, and in infinite recurrence Got trapped For a $ _ GET variable for processing

parse_request , hook and hear, fixed this problem.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -