Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function alltext_shortcode($attribs) {
- extract(shortcode_atts(array('category' => '', ), $attribs));
- global $wpdb;
- $table_name = $wpdb->prefix . 'randomtext';
- $sql = 'SELECT randomtext_id, text FROM '. $table_name." WHERE visible='yes' ";
- $sql .= ($category!='') ? " AND category = '$category'" : '' ;
- $sql .= ' ORDER BY RAND()';
- $rows = $wpdb->get_results($sql);
- $item_count = $wpdb->get_row("Select count(*) items FROM $table_name $where");
- $totalrows = $item_count->items;
- $display = '';
- foreach($rows as $row) {
- $display .= do_shortcode($row->text) ;
- }
- return $display;
- }
- add_shortcode('alltext', 'alltext_shortcode');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement