I want to use spintax to my custom taxonomy term page. I found a code from google that spin text. here is the code below
function spinText($text){
$test = preg_match_all("#\{(.*?)\}#", $text, $out);
if (!$test) return $text;
$toFind = Array();
$toReplace = Array();
foreach($out[0] AS $id => $match){
$choices = explode("|", $out[1][$id]);
$toFind[]=$match;
$toReplace[]=trim($choices[rand(0, count($choices)-1)]);
}
return str_replace($toFind, $toReplace, $text);
}
When I use
<?php echo spinText("{word1|word2|word3}");?>
It assign a new term to the page every time when the page is loaded.
I want to automatically assign a term to a page from the list of accepted terms. The value once set will be not be changed.
For Example :
I have 3 taxonomy terms :
- ABC
- PQR
- XYZ
Now, When I Use "echo spinText("{word1|word2|word3}")"
It automatically assign
- word1 to ABC
- Word2 to PQR
- word3 to xyz or
- randomise
but The value once set will be not be changed on pageload.
Can Anyone help me to fix this problem.