Unknown collation when I import a dump from an existing site into a development database?

This issue is as a result of your server not supporting the utf8mb4_unicode_520_ci collation type. To resolve this you should convert the collation for all tables with utf8mb4_unicode_520_ci to utf8_general_ci If you’re exporting through phpmyadmin, you can: Click the “Export” tab for the database Click the “Custom” radio button Go the section titled “Format-specific options” … Read more

Set meta_key and meta_value for all registered user in wordpress using sql query [closed]

Add this code in functions.php. visit your site you, it will automatic add/update all user meta value. After executing this code just comment out or remove this code. $args = array( ‘fields’ => ‘all’, ); $blogusers = get_users( $args); foreach($blogusers as $key => $user){ update_user_meta( $user->ID, ‘is_activated’, 1 ); } OR you can also do … Read more

Can Someone Help Me Fix This WordPress Missing Argument Error?

As it says in wpdb::prepare Prepares a SQL query for safe execution. Uses sprintf()-like syntax. Thus, if you change it to: $sql = $db->prepare(“SELECT ap.photo_id, ap.creation_date, ap.owner_id, ap.file_id, ap.title AS photo_title, ap.description, aa.album_id, aa.title AS album_title, aa.category_id, sf.storage_path, u.displayname, u.username FROM engine4_album_photos ap LEFT JOIN engine4_album_albums aa ON aa.album_id = ap.album_id AND category_id <> 0 … Read more

Select multiple wp_postmeta keys with single select

If you use get_post_meta() with just the first parameter ( post ID ) you’ll get an array of all the post meta for the passed ID. You’ll get more than you expect but you can then use any number of ways to get the data that you want out. $post_meta = get_post_meta( 207717 )

How to run select query of post with category and tags for API?

WordPress already has an API you can extend, and a class for querying posts! For example: // when the rest_api_init action/event happens add_action( ‘rest_api_init’, function () { // register a new endpoint register_rest_route( ‘mohnish/v1’, ‘/posts/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘mohnish_awesome_func’, // that calls this function ) ); } ); // this is whats … Read more

Updating a checkbox value to database for specific row in table

Rough answer to get you started. Inside the loop, use the row’s record number (a field called ‘IDnumber’, unique, auto) to help name the of a . The hidden <input> should have an id of something like <input hidden name=”idnumber” value=”<?php echo $row[idnumber];?>”> which will cause the vaue of that input field to be the … Read more

How to use MySQL’s MATCH AGAINST in WP_Query?

As far as I know, you can’t use MATCH()… AGAINST in WP_Query. The possible values for comparison are the following: = != > >= < <= LIKE NOT LIKE IN NOT IN BETWEEN NOT BETWEEN NOT EXISTS REGEXP NOT REGEXP RLIKE Which the default is =. However, you can use MATCH() AGAINST in a generic … Read more

MySQL variable in query

See the documentation for $wpdb->prepare(). You need to pass a String, but you’re typing set @csum directly in the parameter. Your code should look like this: if ( is_user_logged_in() ) { $user = wp_get_current_user(); $balance = $wpdb->query( $wpdb->prepare( “SET @csum := (SELECT current_balance FROM exp_ten WHERE tenant_number=%d); SELECT tenant_number, transaction_amount, (@csum := @csum + transaction_amount) … Read more