How can I get an array of all IDs from the current queried object?

You are overwriting $post_ids variable on every while loop, never collecting them. That can be solved using $post_ids = array(); while (have_posts()) : the_post(); $post_ids[] = get_the_ID(); endwhile; var_dump($post_ids); // this is an array of ids However there is simpler way, you can skip the whle cycle and simply run: if( function_exists( ‘wpseo_local_show_map’ ) && … Read more

Multiple User-Meta Values in One User-Meta Key

If you check out the documentation for the update_user_meta() function, you’ll note that the $meta_value parameter already accepts objects and arrays, so you can simply save a user’s positions in an array without any additional effort: update_user_meta( 22, ‘position_names’, array( ‘Khaleesi of the Great Grass Sea’, ‘Breaker of Chains’, ‘Mother of Dragons’ ) ); The … Read more

Replace text inside a huge multidimensional array

Try this php built-in function array_walk_recursive function wpse_do_something_on_data() { $data = array( ‘repeater-1’ => array( array( ‘user_defined_field1’ => ‘http://www.domain-001.com’, ‘user_defined_field2’ => ‘http://www.domain-002.com’, ), array( ‘user_defined_field1’ => ‘http://www.domain-011.com’, ‘user_defined_field2’ => ‘http://www.domain-012.com’, ), ), ‘repeater-2’ => array( array( ‘user_defined_field1’ => ‘http://www.domain-101.com’, ‘user_defined_field2’ => ‘http://www.domain-102.com’, ), array( ‘user_defined_field1’ => ‘http://www.domain-111.com’, ‘user_defined_field2’ => ‘http://www.domain-112.com’, ), ), ); array_walk_recursive( $data, … Read more

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