Check if term object is in array

WordPress has the wp_list_pluck function, which can be helpful here. We can make an array of just term IDs from the array of objects like: $term_ids = wp_list_pluck( $subcat_terms, ‘term_id’ ); Then we can check in_array: $this_id = 42; if( in_array( $this_id, $term_ids ) ){ // do something }

Problem with wp_update_post

The first argument of array_merge is the array of old values pulled from the original post, not your new values, so I’d guess you’re passing an invalid post ID. In your array of new values, I think you want to set post ID to $page_check_404->ID, not $ss_404_post_id.

List of posts by day of the week

What about using just get_posts (removing the order_by argument), then looping through to create and array of programs, then building the output from that: $posts = get_posts(array(‘post_type’=>’programas’,’meta_key’=>’audio_date’)); $programs = array(); foreach ($posts as $post) { $days = get_post_meta( $post->ID, ‘audio_date’, true ); // $time = get_post_meta( $post->ID, ‘audio_time’, true); $found = false; foreach ($days as … Read more

Outputting an array of term meta values in a custom WooCommerce tab?

For your author content display, instead of print_r($all_term_meta); try a foreach: foreach($all_term_meta as $meta) { return $meta[0]; } It’s possible you may need to use “echo” instead of “return” but try “return” first. To control whether or not there is an author tab, update your woo_new_product_tab function with the same condition: function woo_new_product_tab( $tabs ) … Read more

How to check an array of $curauth fields?

Try <?php if ( !empty( array ( $curauth->facebook ) ) || !empty ( array ( $curauth->linkedin ) ) || !empty( array( $curauth->twitter ) ) ) { echo ‘echo me if any $curauth info exists’; } ?> Note: This can be all on fewer lines, I’ve just put in additional line-breaks to make it all fit … Read more

How to validate register settings array

Personally I’d do it the same way, since it seems to be the only point where you can examine user input and validate it. Also, heavily borrowing from code sample in this excellent article: function wpPartValidate_settings( $input ) { if ( check_admin_referer( ‘wpPart_nonce_field’, ‘wpPart_nonce_verify_adm’ ) ) { // Create our array for storing the validated … Read more