List users of specific role instead of removing them with specific role

To fetch users from a specific role, you can use the role parameter of the get_users function. Each role has a specific ID; for WordPress’ native roles, these are administrator, editor, author, contributor and subscriber. In your case, you would want to fetch only subscriber users: $allUsers = get_users( array( ‘orderby’ => ‘post_count’, ‘order’ => … Read more

Merge arrays and order set and subset as one

You can check get_post_meta before args, Example: // Get post meta $game = get_post_meta($post->ID, ‘sd_game’, true); $game_series = get_post_meta($post->ID, ‘sd_game_series’, true); // Check which meta if( !empty( $game ) ) { $key = ‘sd_game’; } else { $key = ‘sd_game_series’; } $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘lyric’, ‘meta_query’ => array( array( ‘key’ … Read more

How to use foreach and if statement within array of arrays?

Figured it out as per this answer. You cannot put any loop or control structure if/else as array value or anywhere within array(). Example $contact_list = []; $contact_list[‘url’] = ‘Website’; foreach ( wp_get_user_contact_methods() as $value => $label ) { $contact_list[$value] = $label; } $settings_fields = array( // Parent array ‘dsbl_basics’ => array( // Child array … Read more