meta query or with meta value

‘meta_key’ => ‘clpr_topcoupon’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ You can solve the problem by using order by clause then there will no need to write meta query. Please use the above code to solve your problem.It will show the posts according to descending order of the value in meta key.

Add to array, redirect and display

If you need to pass some data over the redirect, you can do that by adding parameters to the redirect url with add_query_arg(). But other more elegant solutions might exist also. Single parameter, wp_redirect( add_query_arg( ‘notice’, ‘success’, get_site_url(null, ‘/redirect_to_two’) ) ); exit; or multiple parameters wp_redirect( add_query_arg( array( ‘notice’ => ‘success’, ‘foo’ => ‘bar’ ), … Read more

Conditional multidimensional arrays and array_map

returns with an error (array_map(): Argument #2 should be an array), as no array is present The $states[‘s_bib_source_c_bib_sources’] ?? [] is only setting $states[‘s_bib_source_c_bib_sources’] if it isn’t already set. If it’s set and it’s not an array, then array_map would throw the “should be an array” error. So you might better off use type-casting: isset( … Read more

How to get user ID’s from multiple usernames?

Your call to get_user_by() has a small hiccup in it. It needs to be login rather than user_login // Search these Usernames $usernames = array(‘user1’, ‘user2’); // Fetch the User IDs $prof_ids = array(); foreach ($usernames as $prof_id) { $user = get_user_by(‘login’, $prof_id); $prof_ids[] = $user->ID; } // WP_User_Query arguments $args = array( ‘include’ => … Read more

If Array Values Match Another Array’s Values, Then

Here’s one way to solve this: sort both arrays loop through them and compare them item by item (they should be equal, because arrays are sorted) . sort( $evaltypesReq ); sort( $evaltypesSch ); $containsAllValues = true; foreach ( $evaltypesReq as $k => $v ) { if ( $evaltypesSch[$k] !== $v ) $containsAllValues = false; }