Hi
Im trying and researching for nearly a week now to figure out what seems a simple problem.
Want: Simply autoconvert twitter hashtags to wordpress tags.
Problem: This has to happen before or when the data is published.
function hashtags_to_tags() {
global $post;
$id = (int) $post->ID;
$content = $post->post_content;
preg_match_all( '/\B#(\w*[a-zA-Z-]+\w*)/', $content, $matches );
//wp_set_object_terms( $id, $matches[0], 'post_tag', true );
wp_set_post_tags( $id, $matches[0], true );
}
this works fine when the post already is created and has a ID ...
How i understand it i have to alter the temporary array in which the postcontent is stored before it is inserted in the DB ...
I have gone through post.php and as i understand there are no tags in the temp array and they are added somehow ???
thats the point i dont understand.
How are tags added when you normaly create a post and how can i add my filter/function ???
help would be saving my mental health ...
greets