Get random row from custom table

[Note: @marwyk87 posted his answer while I was composing this, which represents another way to fix the problem] You’ve got a simple syntax error in your SQL, because of the way you’re referencing the table name. You should just say $sql = $wpdb->prepare( ” SELECT * FROM {$wpdb->prefix}quotes ORDER BY RAND() LIMIT 1 “); and … Read more

Tablepress won’t update the table data [closed]

TablePress is simply a plugin that allows you to create tables without coding. You can upload a CSV, sure, but once it’s uploaded, if you want the data to reflect the source CSV, you’ll have to upload the updated CSV to that specific table in TablePress again. Fortunately, TablePress makes this pretty easy with its … Read more

Add table controls with wp_editor minimal editor configuration (‘teeny’)

Finally got it running with few pieces of extra buttons too :): <?php $tinymce_options = array(‘plugins’ => “table,lists,link,textcolor,hr”, ‘toolbar1’=>”fontsizeselect,forecolor,backcolor,bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,alignjustify”,’toolbar2’=>”blockquote,hr,table,bullist,numlist,undo,redo,link,unlink”); $editor_config= array(‘teeny’=>true, ‘textarea_rows’=>5, ‘editor_class’=>’csec_text’, ‘textarea_name’=>’csec_text’, ‘wpautop’=>false, ‘tinymce’=>$tinymce_options); wp_editor($content, $id, $editor_config); ?> Check: wp_editor in add_meta_boxes does not show gallery for better option working in accordance with WordPress.

Get multiple db prefix with $wpdb

Write a function that uses $wpdb->prefix as a fallback. Something like this: function wpse65880_table_with_prefix($table) { // should define array in config file, rather than hard coding $my_tables = array(“table1”, “table2”, “table3”, “table4”); if (in_array($table, $my_tables)) { // “qa_” should also be a config file setting return “qa_” . $table; } else return $wpdb->prefix . $table; … Read more

How to insert more than one row of data into a table at one time

You could use a foreach loop – function mp_install_name_data() { global $wpdb; $table_name = $wpdb->prefix . “names”; $rows = array( array( ‘id’ => ‘1’, ‘name’ => ‘matt’, ‘age’ => ’20’, ‘point_one’ => ‘0.45’, ‘point_two’ => ‘0.22’ ), array( ‘id’ => ‘2’, ‘name’ =>’james’, ‘age’ => ‘6’, ‘point_one’ => ‘0.27’, ‘point_two’ => ‘0.17’ ) ); foreach( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)