How am I able to get the value out of cookie array when I push a button?

You need to put the id of each item inside form to indicate the item that will be deleted. <?php $all_favorites= unserialize($_COOKIE[‘favorites’]); echo ‘<table>’; foreach($all_favorites as $key => $value) { echo ‘<tr>’; echo ‘Post-ID = ‘ . $value . ‘ ‘; ?> <form method=”POST”> <input type=”hidden” name=”id” value=”<?php echo $value; ?>”> <button type=”submit” class=”btn btn-default” … Read more

How to insert new element to existing array in usermeta?

Let’s analyze your code and what it does. Assuming that the current fruits stored in the database are ‘pineapple’ and ‘orange’, get_user_meta(2, ‘fruits’, false) will return something like this: array( array( ‘pineapple’, ‘orange’ ) ) This is because you passed false as the third argument, $single. The function returns an array if $single is false … Read more

How to fetch an array in $wpdb?

You have a problem with your query which is you can’t use GROUP BY and ORDER BY before WHERE replace FROM tablename GROUP BY submit_time ORDER BY submit_time DESC with FROM tablename This is your query $results = $wpdb->get_results( ‘SELECT DATE_FORMAT(FROM_UNIXTIME(submit_time), “%b %e, %Y %l:%i %p”) AS Submitted, MAX(IF(field_name=”Name”, field_value, NULL )) AS “Name”, MAX(IF(field_name=”Email”, … Read more

Create an array with a string key from wpdb->get_results

Found the solution: $currentProducts = $wpdb->get_results(“SELECT feedid, id, size, price FROM products WHERE shopid = $shopid”, OBJECT_K); The OBJECT_K parameter makes an associative array with feedid as key: https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

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.

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