Thanks for the replies.
I never made a plugin beforehand in WordPress but can read some code.
I am trying so it creates the tags automatically on post/update but nothing happens.
I am sure it is something simple that is wrong.
—
<?php
/**
* Plugin Name: TagForWord
* Plugin URI: https://themummichogblog.com
* Description: Create a tag for each word for indexing and SEO and organisation.
* Version: 1.0
* Author: https://themummichogblog.com with code assistance from tugbucket (@tugbucket) – https://www.ads-software.com/support/topic/question-tag-per-word-for-posts/
* Author URI: https://themummichogblog.com
*/
function TagForWord() {
$content = get_the_content(); /* get post content */
$content = wp_strip_all_tags($content); /* remove all HTML */
$content = preg_replace(“/[^A-Za-z0-9 ]/”, “”, $content); /* replace all non-alphanumeric characters */
$content = explode(” “, $content); /* turn all the words into an array at each space */
$id = get_the_ID(); /* et the ID of current post */
wp_set_post_tags($id, $content, true ); /* add the tags */
}
add_action( ‘save_post’, ‘TagForWord’, 10, 3 );
?>