Advertisement
webgeeking

[Plugin: Random Text] Display all

Apr 13th, 2012
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  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');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement