Bulk update post slugs through database

Try this query, remembering to change out your_posts_table with the proper name in your database. Using CONCAT, you can add any number of strings, just pass post_name to add your changes before/after. update your_posts_table set post_name = CONCAT(‘pre-‘, post_name) More info on MySQL CONCAT Note: Use a WHERE clause if you only want to update … Read more

WP Sql query multiple where clause

You can try this with WP_User_Query instead: $args = array ( ‘meta_query’ => array( array( ‘key’ => ‘newsletter’, ‘value’ => ‘true’, ), array( ‘key’ => ‘account’, ‘value’ => ‘false’, ), ), ‘date_query’ => array( array( ‘after’ => ‘2015-01-13 00:00:00’, ‘inclusive’ => true, ), ), ); $user_query = new WP_User_Query( $args ); where I assume your … Read more

Sort users by “birthday” using WP_User_Query

User Meta Query with RLIKE: If the birth date is stored like dd/mm/yyyy, in the user meta, then you could find all August birthday users with the following meta query: ‘meta_query’ => [ [ ‘key’ => ‘birthday’, ‘value’ => ‘/08/’, ‘compare’ => ‘RLIKE’ ], ] You could also consider storing the birthday month additionally in … Read more

Uppercase to sentence case for post titles

You can do that with a command in your database: UPDATE `wp_posts` /* Adjust the prefix! */ SET `post_title` = CONCAT( UCASE( /* First letter uppercase */ SUBSTRING( `post_title`, 1, 1 ) ), ”, LCASE( /* The rest in lowercase */ SUBSTRING( `post_title`, 2, LENGTH(`post_title`) ) ) ); If your author has a habit of … Read more

How to correctly pass values to wpdb->prepare()?

I’ve found an answer by myself.. (sample code) $args_array = array($post_type); $term_slugs = array(‘foto’, ‘video’); // create a string like ‘%s, %s’ ecc $placeholders = implode(‘, ‘, array_fill(0, count($term_slugs), “%s”)); $term_query = “t.slug IN ($placeholders) “; $args_array = array_merge($args_array, $term_slugs); $ids = $wpdb->get_results($wpdb->prepare(” SELECT m.meta_value FROM ” . $wpdb->prefix . “posts p INNER JOIN ” … Read more