I have been working on a code, that finds particular words from my content and converts them to wordpress Taxonomy Tags. I want to prefix them with a '#' symbol... But somehow it doesn't work
This is the code:
preg_match_all('/ #([A-Za-z\/\.]*) /', $content, $matches, PREG_PATTERN_ORDER);
if(isset($matches[1])){
foreach($matches[1] as $matchKey){
$HashTag= $matchKey;
wp_set_post_tags( $ID, '#'.$HashTag, true);
}
The issue is in the second last line of the code...
wp_set_post_tags( $ID, '#'.$HashTag, true);
I put a # symbol behind my text when setting post tags... But when the code executes the # is ommited and only $HashTag is echoed....
I tried to see if the issue is with something else so i tried using other words and alphabets other than '#'
wp_set_post_tags( $ID, 'ABC'.$HashTag, true);
It worked perfectly and had ABC behind each of my tags. I tried to do it with single alphabet and yet again it worked.
wp_set_post_tags( $ID, 'Z'.$HashTag, true);
But still I fail to do the trick with '#' symbol, so please help me out...
Thanks in Advance...