I found the issue was with the polylang plugin. For the above to work I needed to add the language info and in particular associated the tag with the language of the post.
$result=wp_insert_term($tag, ‘post_tag’); pll_set_term_language($result[“term_id”], ‘fr’);
pll_set_term_language is the function provided by the polylang plugin for associating the newly added tag with the language (fr=French in the above example).
Related Posts:
- Query posts from a specific category and selected tag
- Verify if tag is used on posts
- Using $wpdb to query posts with meta value containing current post_id
- Query posts from current year
- Display posts by tag on page
- Convert IPTC keywords to blog post tags
- Order post by year DESC and month ASC
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- How can I display a specific user’s first published post?
- wp_enqueue_media() slows down my WP site
- How can I get all posts data from within a paginated search result?
- Does an action fire when adding a tag via the “Tags” meta box?
- Query posts from different categories in multisite
- posts_per_page doesnt work
- how to programmatically change post tags
- Sorting posts according to view counts not working
- WordPress post tag & custom field
- Only display posts after current date
- How to prevent WordPress from updating the modified time?
- Improving WP_Query for performance when random posts are ordered
- How to add Tags Filter in wordpress admin dashboard
- Prepend or add an Image to the content of a Post
- Get posts by name and taxonomy term
- WP_Query Authors OR Categories
- Get Posts that are in the current month or later
- do_shortcode within post query
- Get Meta Key Value While Saving Post
- Most liked page not displaying posts
- How can I make a post that belongs to a category or have specific tags, display different from the other single posts?
- Query get post,how to add comment box
- Using permalinks, category slugs, and tag slugs
- Print all the tags from a custom post type Please
- Add multiple tags to multiple posts
- get query() without post content?
- WP_Query: Mixing category__in and tag__in together
- How can I setup a relationship using categories in WordPress?
- How to add tags (custom taxonomy) to post class css?
- posts_per_page option limits the number of Gallery items
- How i can limit period of post publication?
- Exclude current custom post on single post
- How Do I Get My Post Tags to Alphabetize?
- WordPress query_posts by tag doesn’t work anymore(?)
- Dynamically switch template on click
- Get all custom post types excepted some…
- Get all comments of author’s posts
- Why Query is returning empty array?
- Delete all drafts?
- Displaying posts that belong to a specific author
- Wrap every month posts in div
- meta_value timestamp older than now
- Display related post by tag name of current post
- Do not show children of a category
- post__in not working with pre_get_posts, but post__not_in does work
- Query for first 3 posts to change the look and feel
- Query posts and filter at query time by value of custom meta
- Very complex post query
- Delete post revisions only for a single post
- See if a post has a specified tag
- How to give classname to post if post has no content?
- Queries take 120+ seconds on my large WordPress site
- How to retrieve certain number of images from a wordpress post?
- Would a “hub” page work better as a page or a post?
- Some doubts about how the loop work (trying debugging it)
- Add post tags to previously created custom post type
- How to display only one category in a custom post type?
- Anyone know a php snippet for showing the first 200 characters of the most recent post?
- Trying to exclude custom posts based on date, while sorting by custom field
- How do I keep raw HTML in my RSS feed and not lose my paragraph breaks?
- How to get tags when using publish_post
- Check if almost 10 year old – working code is up to date
- Query to fetch custom taxonomy along with post title
- How to fetch courses in all languages in WordPress?
- Sync All Post Type Tag
- Excluding tag Link from html tags in Post content
- filter posts based on menu_order
- Show 5 posts and than 3 posts offset with pagination
- I need some explanation on global $post [duplicate]
- How to delete all posts with dead image urls?
- Can I Paginate Post after every 25 tag?
- Querying posts from current category, using a variable as array argument
- Show all posts from the tags without having to set all of them
- Query posts from newest category
- Set multi posts random categories and tags
- wp query custom orderby not custom field
- Query post by meta key of another table
- Query post category & remove any post id
- Ordering posts alphabetically by meta keys and title
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Grab next post title in archive page
- Continuous listing from a custom field
- How to store post rating system data post independent?
- Output posts with same name as tags?
- Should new posts already have tags?
- How to limit post query to only return a total count of items with certain post statuses?
- retrieve post slug by post_tags taxonomy
- Related posts by searching post tags of single post as terms
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Change permalinks in posts via SQL