Category randomizer.
-
Trying to create a php script that produces a random WP category name. So if there are 116 categories currently in the host dbase, the script will identify and use this number (cat_ID ???) to calculate a
(rand()
value. The resulting random number will correspond with a category name.So far my solution has been to create static php arrays of all known WP categories directly into the php script. This makes knowing all categories and calculating a random value quite easy. However, this will obviously always require maintenance to the script as new categories are added to the dbase, as well as make a script that will constantly bloat with more and more arrays. I’m wanting this script to be dynamic, flexible, and lightweight (as it should be). It could be a simple WP plugin when done. Anyone? Skippy???
Example of my current script:
//WP categories
$categories = array("A9" ,"Google" ,"MSN" ,"Yahoo");//enter number of categories from above into rand
$random = (rand()%4);echo ("$categories[$random]");
- The topic ‘Category randomizer.’ is closed to new replies.