Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

[Plugin: Random Text] Display all

By: webgeeking on Apr 13th, 2012  |  syntax: None  |  size: 1.04 KB  |  views: 154  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //For WordPress › Plugin › [Random Text] Version: 0.2.9
  2. // On randomtext.php add the following code on line 198 below add_shortcode('randomtext', 'randomtext_shortcode');"
  3. //You can use shortcodes <strong>[alltext]</strong> or <strong>[alltext category="funny"]</strong>
  4. // webgeeking.com - Shortcode implementation to display all
  5. function alltext_shortcode($attribs) {
  6.         extract(shortcode_atts(array('category' => '', ), $attribs));
  7.         global $wpdb;
  8.         $table_name = $wpdb->prefix . 'randomtext';
  9.         $sql = 'SELECT randomtext_id, text FROM '. $table_name." WHERE visible='yes' ";
  10.                 $sql .= ($category!='') ? " AND category = '$category'" : '' ;
  11.                 $sql .= ' ORDER BY  randomtext_id asc';
  12.                         $rows = $wpdb->get_results($sql);
  13.                         $item_count = $wpdb->get_row("Select count(*) items FROM $table_name $where");
  14.                         $totalrows =  $item_count->items;
  15.                         $display = '';
  16.                         foreach($rows as $row) {
  17.                             $display .= do_shortcode($row->text) ;
  18.                                 $display .=   '<br /> <br />';
  19.                          }
  20.                 return $display;
  21. }
  22. add_shortcode('alltext', 'alltext_shortcode');