Support » Fixing WordPress » Programetically add tags to posts

  • Ok so I’m writing a piece of php code that will automatically give (add) tags to posts based on logics.

    Quick example: Any post that has “Europe” in either the post_content or post_title should be tagged with “Europe”.

    I’ve gotten as far as to be able to get all the post_id’s from all posts that need to be tagged, I got the id of the post_tag “Europe”, and if it doesn’t exist I will first insert it and then get the ID, but I’ve come across a problem.

    The problem is: when I update the tables:
    To completely match what is needed, this meaning:
    – (optional: insert into wp_terms if not exists) and get the term_id
    – (optional: insert into wp_term_taxonomy if not exists) and get the term_taxonomy_id
    – (optional: insert into wp_term_relationships if not exists AND increase the “count” in wp_term_taxonomy by 1)

    However! wordpress does not tag the post, but everything in the database is correctly edited/inserted….

    What am I not seeing?

Viewing 1 replies (of 1 total)
  • Also tried things like using the function


    It does exactly the same as my own code does (makes all the connections/inserts everything in the database) — but it does not REALLY add the tags to the post… Everything is fine in the database, but when I view the posts tags in wp-admin, it just doesn’t show any tags at all…

    What am I missing/overseeing?

    [ Please do not bump, it’s not permitted here. ]

Viewing 1 replies (of 1 total)
  • The topic ‘Programetically add tags to posts’ is closed to new replies.