Wp_footer WordPress hack hidden links
Running a huge cycling blog and gaining a good reputation…
I wanted to split test my post footer in WordPress so I could try out two different Aweber forms. However the forms didn’t display in the way I wanted.
The code I ended up using:
$chosen = mt_rand(1,3);
switch($chosen){
case 1:
include ‘first.php’;
break;
case 2:
include ‘second.php’;
break;
case 3:
include ‘third.php’;
break;
default:
echo ‘something went horribly wrong’;
}
From: Random HTML snippets with PHP include?
This worked very well for me. I simply removed case 3 and changed mt_rand(1,3); to mt_rand(1,2);
This then randomly chose between my first block of text and my second block of text. This meant I could split test their effectiveness by embedding two different aweber forms. When the first form is randomly loaded it counts it in Aweber and then when the second form randomly loads again the results are counted. This meant I could customise the text in a way I wanted and not have to use Awebers built in e-mail forms which were not effective and looked ugly.
Hope this helps someone looking to randomise the way content appears on a page.
Discussion about this post