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

Take filter from multiple functions

You can return $html[‘abc’] and add $html as parameter in each function and to the filter. Exemple for the function: function second_callback($html){ $html[‘def’]= ‘uvw’; return $html[‘def’]; }

Output checkbox per user and save in plugin options

Change the [user] to [users][]. Hope that will fix the problem. Now you’ll get all the value in associative array within [users][‘your-checkbox-data-array’] So your code will be like- <?php $WPusers = get_users( ‘orderby=nicename&role=administrator’ ); foreach ( $WPusers as $user ) { ?> <input type=”checkbox” name=”<?php echo $this->plugin_name; ?>[users][]” id=”<?php echo $this->plugin_name; ?>-users” value=”<?php echo $user->ID; … Read more

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