Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function alltext_shortcode($attribs) {
  2. extract(shortcode_atts(array('category' => '', ), $attribs));
  3. global $wpdb;
  4. $table_name = $wpdb->prefix . 'randomtext';
  5. $sql = 'SELECT randomtext_id, text FROM '. $table_name." WHERE visible='yes' ";
  6. $sql .= ($category!='') ? " AND category = '$category'" : '' ;
  7. $sql .= ' ORDER BY RAND()';
  8. $rows = $wpdb->get_results($sql);
  9. $item_count = $wpdb->get_row("Select count(*) items FROM $table_name $where");
  10. $totalrows = $item_count->items;
  11. $display = '';
  12. foreach($rows as $row) {
  13. $display .= do_shortcode($row->text) ;
  14. }
  15. return $display;
  16. }
  17. add_shortcode('alltext', 'alltext_shortcode');
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement