How to create index (sql) to a meta_key?

I’m not going to tell you about what will happen. I’ll here give you an example on how you can run that piece of sql without phpMyadmin. Add this to your functions.php for temporary purpose. Not to forget about removing this after one run of your website. $mymeta=”_my_first_meta”; $wpdb->query( $wpdb->prepare(“CREATE INDEX wp_postmeta_my_first_meta ON wp_postmeta (%s)”,$mymeta) … Read more

Creating a database in my plugin not working

You have syntax error. You don’t need single quote for column name. You can use phpmyadmin to test MySQL queries. $sql = “CREATE TABLE IF NOT EXISTS $table_name ( id INT(6) NOT NULL AUTO_INCREMENT , user_id TEXT NOT NULL, full_name TEXT NOT NULL, email TEXT NOT NULL, invoiceNumber TEXT NOT NULL, plan_type TEXT NOT NULL, … Read more

How do I display SQL query on a specific page of my wordpress site

$result = $wpdb->get_results( “SELECT `account_number`,`consumer_name`,`bill_amount`,`due_date`,`disco_date`,`bill_status` FROM {$wpdb->prefix}_bill_inquiry where `account_number` = ‘$inputnumber’ AND `pin_number` = ‘$inputpin'”, OBJECT ); $wpdb->prefix will automatically print the prefix, then to convert the result in array form you can use the following snippet: $result = json_decode(json_encode($result),true); You can either place it in a template or you can create a shortcode in … Read more

How to set posts to draft in bulk based on the content of the post

You could try to loop through all the posts and if the content contains the link, call this: change_post_status(get_the_ID(),’private’); or try draft if appropriate. Register this function first: function change_post_status($post_id,$status){ $current_post = get_post( $post_id, ‘ARRAY_A’ ); $current_post[‘post_status’] = $status; wp_update_post($current_post); }

How to add download link from database on custom page template?

/*you’re expecting a single row result so better use $wpdb->get_row ..$id I guess it’s numeric so dont’use quote*/ global $wpdb; $download = $wpdb->get_row(“SELECT realname FROM odm_data where id=”.$id); <a href=”https://wordpress.stackexchange.com/questions/308676/download.php?file=<?php echo $download->realname ?>”>Download</a>

database error WordPress move from one hosting to other

The credentials for your database are located in the wp-config.php file. Make sure those settings are correct. In particular, non-ASCII characters may be causing a problem. Or an extra space in any value (especially the password). Look at the user/pass/dbname in your host also. An extra space at the end of the password in wp-config … Read more

create a table using user meta custom data

See how the data is stored in the database in the table “wp_usermeta” Find the storage keys for “points”, “training completed” Then using the function https://codex.wordpress.org/Function_Reference/get_users $users = get_users( $args ); foreach ( $users as $user ): echo $user->ID; echo $user->display_name ; echo get_user_meta( $user->ID, ‘KEY_POINTS’, $single = true); echo get_user_meta( $user->ID, ‘KEY_TRAINING_COMPLETE’, $single = … Read more