RandomText
RandomText is a handy WordPress plugin that allows you to save, edit and delete categorized text, and inject random/rotated text by category into the sidebar (via widget) or page body (via template tags). The sidebar widget allows you to set an optional Header, and text header and footer. You could say RandomText picks up where the Text gadget left off.
Whether you want to display random/rotated trivia, quotes, helpful hints, featured articles, or snippets of html, you can do it all easily with RandomText.
The WordPress Plugin page is here: http://wordpress.org/extend/plugins/randomtext/
Installation
- Upload `randomtext.php` and `randomtext_admin.php` to the `/wp-content/plugins/` directory of your WordPress installation
- Activate the plugin through the ‘Plugins’ menu in WordPress
- The Random Text widget can now be configured and used from the Appearance -> Widgets menu
- Text entries can be managed via from the Settings -> Random Text menu
Note: During installation, Random Text creates a new database table to store the entries by category – you should see two test records after installation by clicking on the Settings -> Random Text menu.
IMPORTANT: This plugin uses the WP_Widget class introduced in WordPress v2.8 and will not work with earlier versions of WordPress.
Release History
2011-11-03 v0.2.9 – Fixed pagination issues on admin page (again).
2011-06-15 v0.2.8 – Fixed pagination issues on admin page
2011-06-05 v0.2.7 – Fixed numerous issues highlighted by debugging mode.
2010-08-05 v0.2.6 – Fixed shortcode recursion
2010-08-04 v0.2.5 – Added support for shortcodes in text field, Fixed Admin unicode truncation issue
2009-10-26 v0.2.4 – Added shortcode support
2009-09-22 v0.2.3 – Improved handling of “No Category” items, Added Bulk Insert option
2009-08-23 v0.2.2 – Added record id check before timestamp update
2009-08-22 v0.2.1 – Added database table check/error to admin page
2009-08-22 v0.2.0 – Added random/rotation option
2009-08-19 v0.1.4 – Fixed admin path bug
2009-08-18 v0.1.3 – Fixed Pre-text/Post-text bug
2009-08-16 v0.1.2 – Fixed editing issues
2009-08-11 v0.1.1 – minor corrections to readme.txt
2009-08-10 v0.1.0 – initial release
Hi, first off thanks for writing this plugin. It is much more flexible and useful than the others out there, and is really what the Text widget should be.
I have run into a bug where I added 4 new entries, but the widget is only rotating between two. I installed the plugin (v0.1.1) and created 4 new entries with the category “testimonials”. So I now have entries with id 1-6 with 1 and 2 being the default (installer) quotes. 3 – 6 are set to visible and are all of the “testimonials” category. The widget is set to show only “testimonials” and the title, pre, and post text fields are blank.
Hopefully you can reproduce and fix in the next release. Let me know if you need more info.
Thanks
Brandon
Hey Greg,
I’m trying to use the Shortcode to insert a Shortcode that looks like this: [idx-listings city="Castro Valley" orderby="DateAdded" orderdir="DESC" count="10"]
I’m happy to pay to make this happen : )
Any advice? Or, can I get a few minutes of your time?
Hi Sam,
You should be able to use shortcodes in your random text with the latest version (v0.2.5).
Hey Greg – great little plug-in! This has a lot of potential in a nice simple package. I found a problem you might want to address though. I run my production blog out of one sub-directory ( mydomain.com/prod-installation ) but I have a development installation here ( mydomain.com/develop ). Whenever I click to add a new piece of text or click to edit an existing one, I’m getting a 404 page because the plug-in (I think) assumes everything is installed to the root and not to any sub-folder.
Hi Suzanne, I’ve just pushed v0.1.4 which should fix the admin path issue.
I have thousands of lines I wanted to quickly add to the database.. So I made some changes to your plugin;
I added a “mass insert” option which will allow users to paste into the text field as much as they want and add it all via one single click. The data will be broken up by carriage returns..
http://info.rsow.com/files/randomtext.zip
I’m going to make more changes as I see fit. There are a number of things I’d like this little plugin to do that it currently doesn’t do. I’ll keep you posted.
Hi Jason – Bulk Actions and Bulk Import were always on my To-Do List for this plugin, but I hadn’t decided whether to use Copy+Paste or import file.txt (or both). Glad to see my code was clean enough for you to easily alter for your requirements
Yeah it’s fine.. Easy to read and navigate.. (it’s what I do for a living..heh) You beat me to the punch on this plugin by about a day.. I was planning to make exactly what you have made.. I figured I’d just modify what you have and release it back to you for you to either use or discard..
I have more changes I’d like to make but I’m not sure at what point I start to deviate from your design goals..
Hey, where can I download your improved version? http://info.rsow.com/files/randomtext.zip was broken. This seems like a great way to insert misspelled keywords for SEO purposes.
Awesome – thanks for the update. And I agree with jason – your code is nice, to the point and easy to work with. I’m tweaking pieces to accommodate its use with my affiliate work. I’ve got short codes with variable attributes in there that allow me to pop entries in wherever I want them, not just in widgets. Nice!
Hey Guys,
This seems like exactly the plug-in I want and need to display a random image linking to a page on my site.
I’m trying to install the plug-in but get the error when I try to activate it:
Plugin could not be activated because it triggered a fatal error.
Fatal error: Class ‘WP_Widget’ not found in (edited out) …\wp-content\plugins\randomtext\randomtext.php on line 30
Any thoughts about what I’m doing wrong here?
Thanks a million!
Hi Ori, I just checked your site’s page source and you are using WordPress 2.7.1. The WP_Widget class used by Random Text was introduced in WordPress 2.8, so this plugin will not work with your current WordPress version.
I think this plug-in is exactly what I need… I need to insert random text within a page not using a widget. But I feel quite dumb… you say that this can be added through template tags, but I don’t know what tag to add and can’t seem to find info on that here… I’m sure it’s right in front of my face! Point me in the right direction?
Hi Kym, you should be able to use something like this, where category is the group you wish to select from.
< ?php randomtext('category'); ?>Apparently I must be even more of a newbie than Kym. Not clear where to insert the code you just mentioned above to have it show up as the main text on a page…. Thanks!
Excellent, thank you!!
Hi Pants and Kym,
Well, I know this is from 2009, but I installed this plugin and would also like to run random quotes on the pages, not as a widget. Where can I copy in the ??
Cheers,
Victor
would it be possible to make this small script run “HTML code / banner”, because it might be a perfect banner add system, where you have a single spot where it rotates between several banner adds.
I have tested with an older version, and it bugs the HTML code with / before all ” symbols, and every time you edit or change it just ads another one.
I’m using Random Text with to output html and javascript on pantsonhead.com – the slashes problem should have been fixed from v0.1.2. Let me know if you are still having problems with the current version, I’ve just done some quick tests now and couldn’t reproduce the problem.
Hi,
I want to add a random text to the sidebar, what is the function to use it ?
Thanks!
Hi M&M, if you doesn’t want to use the widget, you should be able to use something like this, where category is the group you wish to select from.
< ?php randomtext('category'); ?>
Great, simple plug-in. Thanks much for taking the time to develop it.
I do have one question though. Is there a way I can display the number of the entry as output?
Just the text is output for the entry, I’m not sure why you would want to display the row id. If you can explain why this might be useful I will consider implementing it.
I’m displaying random facts, and I’d like to list the actual number of the fact… for example:
WordPress Fact #26:
Random text goes here.
How can i set the rotation to only once per day? I’m using this to display a name of the day so I don’t want it to keep displaying a new name.
Regards
Pattie
Pattie, This is probably the wrong plugin to use for that, everything is geared towards displaying something different each time the page loads, not by time period.
Is there any way to get the code changes to make this accessible through shortcodes in a post? I desperately need this functionality.
Thanks much,
John
Great plugin!
I have two questions:
1) How do I change the line-spacing within the box? I’ve tried to do it through the theme’s stylesheet, but it’s not working. Perhaps this has something to do with the plugin?
2) Is it possible to display more than just one text? If so, how do I do it?
Thank you in advance for your help!
Kevin
Hello, me again. =)
Never mind the first question. I figured it out. (I’m clueless when it comes to code.)
The second question still applies though. Again, much appreciated. Thanks!
Hi Kevin, You’d need to use two instances for 2 elements to display. Hope this helps.
Can I pay you to add shortcode functionality to your plugin? I really need it now. Please email me.
Hi John, I've just pushed a new release of RandomText with shortcode support.
I just happened to check back at your site today. Glad I did. A THOUSAND THANK-YOUS!!! You are a life saver!
Cheers!
than u a lot
i use it at my blog
http://www.pallap.com/m/
thanks
Thanks for the plugin! It's posible to change the quotes font size?
You can control the display style by adding a randomtext class to your stylesheet.
Thanks but I have started to use WordPress recently and I don’t know how I can do that. Can you help me (if it isn’t to ask too much), please?
Hi! I made modifications in RandomText. I've added support for i18n and possibility to use TinyMCE editor for editing content. I was not able to find Greg's e-mail, so here is updated version – http://georgik.sinusgear.com/wp-content/uploads/r...
Greg. Please, check whether you like those changes and consider whether it's worthy for official version
Ou! For some reason URL was chopped and it’s pointing to wrong URL
Correct is :http://georgik.sinusgear.com/wp-content/uploads/ – and – randomtext.tar.gz
can I add the code from RandomText into this section:
What about…yea, you`ve guest it
and how can I do it? If i try to put it as a widget it just won`t fit the size of the box.
Regards
Thank you for this Plugin! After installation there ist a message “Achtung! The expected database table “wp_randomtext” does not appear to exist.” There are no entries and I cannot create categories.
Wolf
It sounds like you don’t have access to create the new “wp_randomtext” table in your WP database. If this is the case then this plugin will not work for you.
But I didnt have problems with other plugins that create mysql-tables.
I dont know why this happens with RandomText.
Maybe in this case I can add the table via phpmyadmin manually.
Hi
Awesome plugin! Thanks!!!
I’ve been messing with css stylesheet to modify the font and the display. Here is the dev site I’m working on. http://ramzydezigns.com/Demos/Artecrete/
Trying to get the title of the RandomText Widget to line up separately from the Text.
I’ve entered this into my stylesheet
randomtext {font-size:12px;
font-weight:normal;
padding:10px 10px 10px 10px;
but it pushes the whole thing to the right (including the title bar). I’ve tried various CSS properties, but seems the text and the title are linked. is there anyway to give padding or a margin to the TEXT, but not the title?
Thanks!
Hi Matt, It looks like the testimonials header is conflicting with the padding. Maybe you could try something like this:
<h2 class=”widgettitle” style=”margin: 0pt -20px;”>Testimonials</h2>
.randomtext {
font-size:12px;
font-weight:normal;
padding:10px 20px 0;
}
Hey Greg,
Thanks for the tip. I’m messing around with it, but can’t seem to get it to separate still… I’ll keep fiddling….
I’m having trouble with the style of the widget. It’s not reflecting the style outlined in the CSS. Any thoughts? I’;m using the iPortfolio WP theme
[...] Read the original post: RandomText « Pants On Head [...]
How do I Stop the Madness!!!???
I have had this wonderful RandomText widget running for a while with no problems, and a lot of happiness.
All of a sudden, the thing has decided to duplicate some of the entries – a lot!!! – like 300 times for the same one.
Deleting one at a time is really tedious. Oh yeah, REALLY tedious!
Is there a way to delete, say #150 – # 500 (or so)? or a block of 10? My fingers are not made for this.
BTW – it MAY have been caused by one of the entries having an asterisk, but I otherwise have no idea. It was just there when I got to work this morning, and I’ve been semi-dealing with it all day.
Thanks – otherwise, a great plugin.
Thanks for this great plug in – just what I needed. The bulk upload is a great idea – any chance you might add a bulk delete option too? I think @Earnest Most would find it useful too
Thanks again!
Sorry if this is painfully obvious, but I haven’t found it documented… when using the shortcode
eg [randomtext category="funny" random="1"]
What is the significance of the random=”1″ and what happens if it’s not used? I’m assuming that it toggles between random and sequential, but can anyone confirm?
Yes it toggles between random and sequential
Hi,
Thanks for a great plugin! I’ve installed it on this non-profit site that is under development. I’ve run into one snag, though – the folks who will be adding content on the site will have Editor roles, and the rotating text settings aren’t available to that level! I installed a role manager and tried giving “manage options” capability to the editor, but while other settings that I’d just as soon not expose to the contributors appear, the rotating text one still doesn’t.
Do you know of a way I can give the contributors on this site the ability to add, edit and delete their own texts, without making them all Administrators?
Thanks a boodle,
pq
[...] RandomText – ランダムテキスト表示ウィジェット [...]
[...] Damit auch meine Blogleser etwas von diesen Best-of-Twitter-Perlen habe, zeige ich eine Auswahl dieser Tweets hier im Blog an – wild durcheinander gemischt (ein Kinderspiel mit Random Text). [...]
I made a simple modification to this plugin because if my random text had in it other shortcodes, they were not parsed.
So i added one simple line in randomtext.php, at line 56:
$snippet = apply_filters(’the_content’, $snippet);
Works perfect now
Hi Silvester,
This functionality is now available from v0.2.5, although I opted for a sllightly different implementation and used do_shortcode().
I symlink my plugins directory and so the plugin is not creating the table in any of the wordpress installations except the non-symlinked root install. But if I run the SQL to create the table then the plugin works fine in any of my installs. Here is the SQL for those who have a similar issue with creation of database tables.
–
– Table structure for table `wp_randomtext`
–
DROP TABLE IF EXISTS `wp_randomtext`;
CREATE TABLE IF NOT EXISTS `wp_randomtext` (
`randomtext_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`category` varchar(32) CHARACTER SET utf8 NOT NULL,
`text` text CHARACTER SET utf8 NOT NULL,
`visible` enum(’yes’,'no’) NOT NULL DEFAULT ‘yes’,
`user_id` int(10) unsigned NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00′,
PRIMARY KEY (`randomtext_id`),
KEY `visible` (`visible`),
KEY `category` (`category`),
KEY `timestamp` (`timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
–
– Dumping data for table `wp_randomtext`
–
INSERT INTO `wp_randomtext` (`randomtext_id`, `category`, `text`, `visible`, `user_id`, `timestamp`) VALUES
(1, ‘Installer’, ‘Creativity is the ability to introduce order into the randomness of nature. – Eric Hoffer’, ‘yes’, 2, ‘0000-00-00 00:00:00′),
(2, ‘Installer’, ‘So much of life, it seems to me, is determined by pure randomness. – Sidney Poitier’, ‘yes’, 2, ‘0000-00-00 00:00:00′);
[...] Random Text [...]
Thanks Greg for good plugin!
One thing, it was a problem with Russian cites in admin page. Some items were blank in admin page while the correspondent text exists in database.
the problem was with UTF-8 encoding
$row->text = trim(substr($row->text,0,350)).’…’;
After I’ve changed it to
$row->text = trim(mb_substr($row->text,0,350,’UTF-8′)).’…’;
everything works like a sharm!
A
Hi Andrey Kostin,
Thanks for the suggestion – I’ve implemented this in the latest version (v0.2.5).
Thanks for your wonderful plugin! I’m developing a WP theme that uses it now. In your description, you say that with large recordsets, some results may never appear. In an attempt to rectify this, I have replaced MySQL’s “ORDER BY RAND…” with PHP’s way-more-random mt_rand().
I also set the modified function up so that the result is ALWAYS random by removing the $random variable, but one could always put it back…
In randomtext.php, I modified these two functions as follows:
function get_randomtext($category = ”) {
global $wpdb;
$table_name = $wpdb->prefix . ‘randomtext’;
$sql = ‘SELECT randomtext_id, text FROM ‘. $table_name.” WHERE visible=’yes’ “;
$sql .= ($category!=”) ? ” AND category = ‘$category’” : ” ;
/* Get all rows as associative array
[$rows] => ARRAY
(
[$rownum] => ARRAY
(
[randomtext_id] => *INT*
[text] => *TEXT*
)
)
*/
$rows = $wpdb->get_results($sql,ARRAY_A);
// $rows index starts at zero, so we have to subtract 1 to include the first row
$rownum = mt_rand(1,count($rows)) – 1;
// echo $rownum.”";print_r($rows);echo “”;
$row = $rows[$rownum];
// echo “”;print_r($row);echo “”;
// update the timestamp of the row we just seleted (used by rotator, not by random)
if(!$random AND intval($row[randomtext_id])) {
$sql = ‘UPDATE ‘.$table_name.’ SET timestamp = Now() WHERE randomtext_id = ‘.intval($row[randomtext_id]);
$wpdb->query($sql);
}
// now we can safely render shortcodes without self recursion (unless there is only one item containing [randomtext] shortcode – don’t do that, it’s just silly!)
$snippet = do_shortcode($row[text]);
return $snippet;
}
function randomtext($category){
$randomtext = new randomtext;
echo $randomtext->get_randomtext($category);
}
I hope you can put this to some good use.
Hi Greg, thanks for the excellent plugin! I have tried many banner-widgets but your plugin is the easiest to use. On one site I use your plugin to display random quotes and on another I am using it for displaying images (banners) and it works perfectly!
Thanks for the great plugin! I love it. I was searching for a random plugin to show my ads shortcode. I tested a lot of ads plugin, but none of them really fit my needs. Most of them are just too complicated or can’t do what I want. This plugin can print my shortcode easily and show the ads without problem. It’s just like a random ads plugin
.
Just a suggestion, if the script can let people select where to show the random text (e.g. below content, above content), it will be even better
. I am currently using another plugin to select where to show the ads.
Nice plugin. Is there anyway for me to make this a bolder font and give it a bullet point before it.
Man! Great Plugin.
I wonder, why you don’t offer a Paypal Link to send a small thank you fee
… I would like to give at least a few dollars to say “thanx!” … honestly
ray
Awesome plugin – thanks for putting this out there
One suggestion I would make for possible future releases – it’d be great if there was a shortcode to output a list of all texts on a page.
I think I wouldn’t be alone in using this plugin for random testimonials in a sidebar, and my clients will no doubt be using your plugin like this in future, but it would be great if they could add a testimonial to the plugin and have it appear both in the sidebar, and also on their dedicated “testimonials” page – without having to manually enter it in both places.
I know you mentioned in a previous comment that you could use multiple instances of the usual shortcode [randomtext], but this still would require a double-entry by the client to get it to show u in both.
Just a thopught – but yeah, loving the plugin – great work
Thanks!
Thanks for this plugin – it was exactly what I needed!!
[...] Random Text: Ein simples Plugin. Hiermit kann man, wie mit dem WordPress Text Widget, Quellcode in die Sidebar einfügen. Allerdings mit dem EXTRA das sich der Text auf Wunsch bei jedem Seitenaufruf ändert. [...]
I’m using this as a simple headlines rotator with in a template using the tags:
(or whatever it is)
How do I make it rotate the text, say every 5 seconds and not just when the page is reloaded?
Hi -
Thanks for a great plugin. I just implemented for a client using shortcodes on his homepage at: http://ipginc.net.
Do you have a list somewhere of all the shortcode parameters available? Also, I am wondering if there is an ability to have the quotes rotate without page reload… like a slide show? Thanks.
Hi – Thanks so much for this plugin. I’m using it and would like to know if you could create a customized version for me which would also play an mp3 – say by clicking on a small speaker icon?
Thanks for this plugin. I really appreciate your work and it’s made my life easier.
This is a great plugin. My suggestion: On the admin screen, just put some explaination text of the different ways to call the plugin with the different options (I keep having to refer back to the WordPress.org plugin page for the usage options).
Hi,
Does this plugin pull the quotes from a jquery? I have other plugins that do and I just don’t want them to conflict. Thanks! I don’t want to activate it, imput my random text and then shut down…
[...] TextThings like customer testimonials or random
quotes are handily managed with tools such as Random Text and
Quotes Collection.WordPress Theme Design FlexibilityThere are
plugins to make Themes easier to [...]