0

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 :

  1. ABC
  2. PQR
  3. XYZ

Now, When I Use "echo spinText("{word1|word2|word3}")"

It automatically assign

  1. word1 to ABC
  2. Word2 to PQR
  3. word3 to xyz or
  4. randomise

but The value once set will be not be changed on pageload.

Can Anyone help me to fix this problem.

artless noise
  • 21,212
  • 6
  • 68
  • 105
jack
  • 1

0 Answers0