On: 2005/04/29
Shorter URL for this page: http://ozh.in/l4

Random Words is another completely futile plugin which aims to bring entropy and randomness into your pages and even posts.

Ever got bored by comment pages with the same "Joe said", "Jim said" all page long ? Wouldn't it be funnier and more attractive if it printed something randomly from "thought", "wrote", "said" and "commented" ? Here we are.

Random Words is a WordPress Plugin allowing you to manage a number of lists with any items, and display random items from these lists. Everything is managed from within the Admin interface of your blog, in a very neat interface. It stores its data in two fields of WordPress' built-in Options table, and displays random entries at no cost (no extra SQL query used to fetch items)

Get it

Download the plugin :
ozh-random-words.zip
Extract and upload to your blog, preserving directory structure if any.
Note: download counter here and stats on wordpress.org may differ and reflect the number of downloads before this plugin was hosted on the plugin directory

Activate it, go the options page and follow the instructions.

Use it

Use the following syntax :

  • In .php documents :
    <?php wp_ozh_randomwords('name_of_list') ?>
    If you want the result returned but not echoed, add a second parameter with value zero :
    <?php $test = wp_ozh_randomwords('name_of_list', 0) ?>

  • In Posts or Pages :
    [random:name_of_list]

I don't see any reasonable use for this in posts, but well, I had to do it :)

Watch it

For example, I created a list named "you_are" with the following entries :

  1. a nice person
  2. a <em>porn star</em>
  3. so <em>cute</em> !
  4. <span style="color:purple">teh master of teh intarweb</span>
  5. reloading the page
  6. pretty. Well, sort of.

In this page I wrote :

  1. I see, I see ... that you are [ random: you_are ]

The result is (reload to see it change) :
I see, I see … that you are a nice person

Keep list names short and avoid funky characters, but use anything including HTML in the entries. It has to be one-liners, but you can insert a manual <br/>

Push it

A few suggestions, or examples of use (name of the list, followed by items of the list)

  1. trackback: trackback, pingback, chmlmlback, stuffback, sumthinback, trackpingback
  2. comment: wrote, said, replied, thought, commented
  3. emphasis: extremely, wickedly, awesomely, completely

You could also use it as a Quote of the Second script : create a list named "quotes" and add entries like :

  1. <em>640K ought to be enough for anybody.</em><br />&raquo;<strong>Bill Gates</strong>, 1981
  2. <em>A fast word about oral contraception. I asked a girl to go to bed with me, she said 'no'.<br />&raquo;<strong>Woody Allen</strong>, yesterday
  3. ...

Tell me

Got a suggestion, a bug report, something to tell, to thank or to complain about ? Using this plugin on your blog ? Made something fun with it ? Tell me !

Shorter URL

Want to share or tweet this page? Please use this short URL: http://ozh.in/l4

Metastuff

This page "WordPress Plugin : Random Words" was posted on 29/04/2005 at 9:45 pm
Watch this discussion : Comments RSS 2.0.

87 Blablas

  1. RaynerTheApe says:

    Excellent plugin! I have added random comment verbs already but also tried to combine your plugin with the plugin CA-Credits, which adds a "Thanks to {commentors} for commenting." Which uss the following PHP call:


    I tried adding calls to your plugin as follows


    When I execute this PHP call I get all the random words in the beginning and the database query result after the random words like:

    Thank youfor commentingand User 1, User 2, User 3….

    I don't understand this behavior, and it might be some PHP problem with calling one function from another… if you have any idea how to fix this, I'd be really greateful. I want to make the "Thank you" plugin a bit more enthropic and as if I write it by hand.

  2. Ozh says:

    I think you didn't understand how my plugin works. There's no need to create thankyou1, thankyou2 and stuff. Create just *one* list, named 'thankyou', and populate it with "Thanks", "Thank you", "I kiss", "Thx 2" or whatever.

    Then, I'm not using ca-credit but from what I understand of how it works, combine function calls like this : replace its first argument, "Thank you", by a call to my plugin which will return, not print, a random entry.
    So the original code :

    Becomes with my plugin embedded :

    Should work fine (and by the way this is a nice idea of fun plugins combo)

  3. RaynerTheApe says:

    Thanks for the help. I might use this, but I was hoping I could have three random lists that change all the strings. For example I wanted to have "for commenting" changed sometimes with "for daring to comment", etc. Basically every scripted message I want to have it randomized. So then it sould be like…?

  4. RaynerTheApe says:

    Okay, solved it myself. It was the 0 parameter in your plugin's PHP call. The proper code should be:

  5. RaynerTheApe says:

    One last thing. I've noticed that the random generation is not really that random – one of the choices usually seems to be appearing in 2/3 of 8-9 cases. I don't know if you've noticed something like that, or it is that I have very few (5-6) random words in a list.

  6. cosa says:

    to make it more random, i think you should change rand() to mt_rand(). According to PHP documentation, mt_rand() function will return a better random value.

    btw, nice plugin Ozh :)

  7. Ozh says:

    Thanks for the suggestion, I've changed it

  8. How to Combine CA-Credits with Random Words Plugin

    Couple days ago, Ozh released a nice plugin called Random Words. This useful multi-purpose plugin is used to display random text (not words actually ) from a specified list. You can use it to display random quotes, random verse, random image, etc.
    O…

  9. Charles says:

    Hey, just started experimenting with WordPress and ran across your plugin, I'm using the latest WordPress install, but get an error when trying to access the "Options" tab "Random Words" Fatal error: Call to undefined function: add_action() in /wp-admin/wp_ozh_randomwords.php on line 327. Any ideas what i'm doing wrong on the install?

  10. Ozh says:

    Sure. The file must sit in /wp-content/plugins, where every plugin file must be.

  11. cj says:

    im new to all this stuff…but i put in your plugin. it comes up in the plugin field, i activate it and create a list. however, when i put in the little php line in my sidebar it does not show up? what am i doing wrong? probably a lot of things…but any help would be appreciated.

  12. johngb says:

    Hi Ozh – I've just installed both this random word plugin and the click counter – both great ideas!

    I'm having a little trouble with this plugin, though – I thought that it would be great for using as a description of comments: e.g. '1 snappy retort' or '5 snide remarks' etc., instead of the boring '2 comments' type of thing.

    I made a list in the options tab of WordPress called "comment" but when I went to embed the code

    into the index.php
    file (I was editing in the admin pages) I would always get the error message:

    Parse error: parse error, unexpected T_STRING in /…/blog/wp-content/themes/GeminiBlue/index.php on line 22

    I tried embedding the same string as above in another part of the page and it worked just fine. I think that the problem was to do with the fact that there were round brackets and apostrophes around the code. Here's exactly what it looked like in context:

    '), __('% s')); ?>

    Any help would be great!

    John

  13. Ozh says:

    John, send me an email or paste the code you are trying to use.
    I'll have a look.

  14. johngb says:

    Okay good idea – the paste is here.
    Thanks again!

  15. Ozh says:

    Solution is here.

  16. johngb says:

    Thanks heaps mate – Australia loves you.

  17. […] Die installierten Plugins (darunter Gravatars, WordPress HashCash und Random Words) werde ich beibehalten, wenn auch manche leicht abgeändert (Technorati Tagging). […]

  18. 4ndr3w says:

    Hi:
    Great plugin, I use it to display random FireFox banners. One major problem though, after I installed it, I noticed that instead of showing my posts, it says:
    Warning: call_user_func_array(): First argumented is expected to be a valid callback, 'wp_ozh_randomwords_spostcontent' was given in /home/bobturbo/public_html/andrew/wp-includes/functions.php on line 927

    I have no idea what to do.. please help =]

  19. Ozh says:

    Andrew » I have no idea of what you're trying to do. 'wp_ozh_randomwords_spostcontent' is obviously not a function of my plugin.

  20. […] 後來想到我有訂閱慈濟的電子報,而我原本就有用Random Words來當隨機出現的 每日靜思語,感覺還不錯啦~~慈濟電子報除了會有每日靜思語之外,偶爾還會有證嚴說故事~證嚴上人開示,就是用一篇短短的故事來說明一些道理,我感覺還不錯,後來就想說,乾脆把這個放在aside好了,除了我自己的gmail都有留下每封mail之外,順便在這裡也作個備份吧! 有緣看到的人也算是結個緣囉~~ […]

  21. SecurityWonk says:

    Can't get this to work on my wp 2.02 install. When I click on Options > Random Words it tries to go to ../wp-admin/wp_ozh_randomwords.php. This file doesn't exist. What am I doing wrong?

  22. yoli says:

    When I try to create a list in WP 2.0.2 I get this error message:

    Warning: array_push(): First argument should be an array in /home/dragoonn/public_html/yellow7/wp-content/plugins/wp_ozh_randomwords.php on line 235

    Have I downloaded/uploaded the file incorrectly or is it just not WP 2+ compliant (yet?)? I really love this script so if it's the latter, do you have plans to make it so soon? It is hands down the best randomization plug-in I've found for my quote hoarding tendencies.

  23. Rex Strother says:

    Love it. Couldn't find a random image + caption generator for my news satire "blog" (without building a gallery somewhere) – but your plugin does the trick neatly, since it allows for the line to include HTML.

    Random "Words" is generating the "Breaking News" image and caption in my Column B.

    http://www.lowlights-now.com

    Thanks so much! And I'll be using it elsewhere on the site with other lists. Thanks so much.

    Question: I notice that hyphenated words (like "drug-induced" will not break at the hyphen and are forced to the next line; could that be changed?)

  24. review says:

    random text+

  25. Marci says:

    I have been enjoying this plugin for some time without issue, but today I tried to make a new list, and change an old one, and I keep getting "Something went wrong: unable to save lists in the datadase." Is this using the MySQL database? And if so, what is the table name? I can tell that the admin function is pulling data from somewhere, and it's all showing up on the site just fine, but I need to locate the database (or find how/where it's being called by the script) so I can figure out what's up. Thanks!

  26. Ozh says:

    Marci » everything is stored along with WP options, i.e. in a line inside table 'wp_options'

  27. Sindhu says:

    nice plugin, havent tried it as yet, will in a while. and i must tell u ohz, i cant live without that drop down menu plugin life saver! :D its gotta be there in all wp installations, feels like shit without it. thankx a lot :D

  28. Dmitri says:

    A small tip for everybody, who wants a random -tag text. Edit your html like this:



    Didn't find info about this second parameter "0", so had to search thru php code :)

  29. Ozh says:

    Wow, THAT's a smart use, thanks for the idea I like it :)

  30. Marci says:

    I posted back in October that I could not get the plugin to write to the database (“Something went wrong: unable to save lists in the datadase.”) and I am still having the problem. I can now find the data in MySQL, but I can't figure out how to get the plugin to save/edit. This was all working fine at one time. Any hints on what to check to resolve this? It's a really important part of my site, and I love this plugin!! Thanks :)

  31. Marci says:

    Just checking to see if there is any hope for my problem. Has anyone else experienced this? What would cause the DB to not accept input from this plugin? Any ideas would be appreciated. Thanks!

  32. Marci says:

    This is wierd…in spite of an error message which says it cannot write to the database, in actuality it IS writing to the DB, but it just generates the error message anyhow. Any idea why that would happen?

  33. Steve says:

    Nice plugin Oz – thanks a lot. I'm using it to pick out random sponsors who have donated to my daughter's fundraising – you can see it at http://www.emilydunnett.com on the sidebar and thank you page.

    Any chance you could tell me a function to just return all the words in a list so I could format up a sponsor cloud. You wrote the code in a compact and excellent manner and while I will be able to get it in the end it might be a feature other people could use also.

    Thanks again!!

  34. […] Random Words – from within a neat admin interface, manage lists of "items" (words, quotes, images…) and display random items in your pages or posts. […]

  35. […] 就是显示留言者来源国家的东东. 今天再次去PlanetOzh寻宝, 把Random Wordså’ŒClick Counter两个东东装上了, 其中的Random […]

  36. gina says:

    I need some words for a title for my song. It's about a guy I dated and what not, well I always give gifts to him and he never give a gift to me. So I'm writing a song about him but can't find a title for it.

  37. Ozh says:

    Name it: "the girl who had no clue about the sites she was reading". Duh.

  38. Pixelation says:

    Insane! This is the greatest plug-in I have ever used! And I mean that so seriously: I have rotating blog descriptions on my header that I'd been using bulky javascript to produce.

    I think you just shortened my load time by half and made my list so much easier to access. Kudos

  39. […] Although my articles page calls attention to what I feel are my best posts. Last and greatest is Ozh's random words. Now, whenever you comment, it's just as likely to say "You bitched" as […]

  40. […] onledig gehouden met het verzinnen van "random words" voor hier op mijn blog. Je kan het dink overal voor gebruiken tot in de reacties toe. Meer verklap ik niet. Zo geestig. F5-en rulez! En zie […]

  41. […] Random Words es un plugin para WordPress que permite manejar listas con cierto número de elementos, y mostrar elementos aleatorios de cualquiera de ellas. Se maneja desde la interfaz del admin y se puede citar cuantas veces y en cualquier parte que se desee, hasta lograr cuanto entropismo de contenido pueda parecer necesario. Random Words es también nuestro about que es una lista de citas aleatorias distribuidas en la página. estas han sido seleccionadas por su elocuencia y valor descontextual. es un sampler. y un looper, para verlo, F5. Algunas de las frases pueden ser fácilmente reconocidas, otras menos. La lista esta abierta a sugerencias. Pueden comentarlas o enviarlas a about|en|ritalink|punto|org tags// […]

  42. navayo says:

    Hi i just installed the plugin and activatet it, but when i go to options -> random words i just get an empty 404-page. what can i do?

  43. Ozh says:

    navayo » don't know… Install properly, perhaps ?

  44. […] Random Words : adds the ability to play with 'random' lists without to much hassle. I'm sure I shall think of some neat ways to use it. Either that or it stays 'disabled' until eternity. ;) […]

  45. FD says:

    I was wondering if this works with WordPress 2.3? I've been trying to add it to my comments but so far I haven't been able to get random words to show up.

  46. Ozh says:

    FD » works fine on my 2.3 installs (should work on 1.5 up to 2.5)

  47. FD says:

    Thanks for the response. It's entirely possible and probable that I'm doing something wrong. Basically, I'm just trying to place it in my comments and have it replace the typically "said" with something I choose. Is there any chance you can tell me where exactly I need to put this to make it happen? I'm using the Vistered Little 1.7.6 theme and WordPress 2.3.

    Thanks.

  48. torquemada says:

    hi OZH,

    i tried it but in posts apears always the complete list, not only one random word of the list. What could be wrong ?

    Is it always necessary to integrate the "" part or the "[random:name_of_list]" paart works alone also ?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.