Questions tagged [array]
An array (in PHP) is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.
766 questions
1
vote
0
answers
43
views
Loop Through PHP Array, Match Partial String, Return Values [closed]
I am working with Wordpress to build a weather website and I have a little bit of a complicated piece I'm trying to do. I have a static JSON array of record high temperatures for each date in a year. ...
0
votes
0
answers
51
views
Updating from multiple array custom table
This is similar to a question that hexalix helped me with recently.
Trying to update a table from a multiple field form
I tried using similar code from that question but to no avail.
Form field as ...
1
vote
0
answers
56
views
prepare select of array
Odd one this.
I have been working on this particular query for a few days now.
The idea is to use the variables selected from first query to be used in second.
($project_id = $_GET['project_id'])|| ($...
0
votes
1
answer
40
views
Array() displaying in all pages of admin -view page source
When we check view source page of our site, it is displaying below code in all pages :
Array
(
)
below is screenshot :
Requirement :
How to remove that Array() text ? From which file it is coming ...
0
votes
1
answer
71
views
Orderby meta _value that is saved as an array
I want to order a WP_User_Query by a meta value. The meta key is a multi-select field, and the value is saved as an array.
When I do a print_r of get_user_meta($user_id,'committee',true) this is what ...
0
votes
1
answer
63
views
Is there a way to use MySQL JSON functions in meta queries?
There are JSON functions: https://dev.mysql.com/doc/refman/8.3/en/json-search-functions.html can be used to search in complex data with MySQL. In the case of meta keys and values it is an issue that ...
1
vote
1
answer
108
views
Parameter for pagination posts_pagination
I created a pagination with the_posts_pagination() function
Right now it looks like this and it works fine:
Previous 1 2 3 4 Next
When I am on the 1st page, the "prev" button disappears or &...
0
votes
1
answer
353
views
posts_results filter - additional sort, with a meta value, to move posts to the end of the results, with pagination working
I have a custom post type for business locations that I am trying to add an additional sorting filter to by using a custom meta value. The custom field specifies whether or not the location is open or ...
0
votes
1
answer
32
views
PHP - Converting elements to actual values
I made a list of checkboxes that upon click would be sent to database.
Every time I submit data the value is 0. If I try and convert the value of the array to string, I get string to array error.
<...
1
vote
1
answer
157
views
Display custom post type attached media file sizes
We have a custom post type slugged 'download' and it acts like a posts but with the different slug. (It displays content like a post). Now, We have a custom field named "videos" and ...
0
votes
1
answer
1k
views
How to group by column a and sum column b and c in a php array
I got the following array:
[0] => Array
(
[kanel] => 5
[peber] => 0
[shipping] => A
)
[1] => Array
(
[kanel] => 25
[peber] => ...
0
votes
1
answer
43
views
How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
I have a CPT with daily deals, I need to show these daily deals on my frontend as per today's day.
For eg, if it is Thursday : The returning array should return Thursday, Friday, Saturday, Sunday, ...
0
votes
0
answers
178
views
save array of objects with update_option
How do I save an array of objects in Wordpress/PHP via update_option ?
What I'm trying to save is something like:
update_option('my_option', [
{
'c': htmlspecialchars($_POST['hidden_category']),
...
0
votes
1
answer
636
views
How to get files from loop for zip
I am working on a button which will download the images as a zip on specific posts. It works if I leave the files array in functions.php with a few hard-coded img links. But when I move the array to ...
0
votes
1
answer
27
views
WordPress emails error regarding the argument type even if the type is correct
function test_sort_terms_hierarchicaly( Array &$cats, Array &$into, $parentId = 0 )
{
if ( is_array( $cats ) ) {
foreach ( $cats as $i => $cat ) {
...
0
votes
1
answer
901
views
Custom WordPress Function - Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
I've searched far and wide for a solution to the problem. I'm almost there, but can't seem to get it working completely.
Background
There are 3 post types that are involved in this function: League, ...
0
votes
1
answer
44
views
Order Categories by Character Count
I'm developing a medical directory website in Wordpress, and in the Grid/List pages for the site, each of the listing cards contains a list of specialties (using the category taxonomy within the ...
0
votes
1
answer
44
views
Update value inside array update_post_meta
I am trying to change default values inside array in custom field.
But I am getting error "PHP Fatal error: Uncaught Error: Cannot use string offset as an array" when I try to change the ...
0
votes
1
answer
643
views
Check if user has comment on current post
Hello I have multiauthor website and I need to create a condition to check if defined user ( no current user ) has comment on current post.
Here is my code but I can not complete this
$userid = "...
0
votes
0
answers
237
views
Custom Field: how to save array of multiple key-values in WordPress
I have this kind of data on my database:
<wp:postmeta>
<wp:meta_key>
<![CDATA[property_icalendar_import_multi]]>
</wp:meta_key>
<wp:meta_value> &...
1
vote
0
answers
95
views
Populate dropdown with Child Pages based on Parent Page chosen
I'm trying to populate the Child Page dropdown with that of the selected Parent Page - If a specific Parent page is chosen it should fill the second dropdown with all Child pages listed under that ...
0
votes
1
answer
161
views
update_post_meta() updating nested array in Multidimensional array with empty sub-array
How can i update/remove/empty a sub-array on user post submission in admin area?
here ist the reference on how to update nested array i am using but it is not working
if ( $post->post_type == '...
0
votes
1
answer
221
views
Combine 2 arrays in a query parameter
I'm trying to exclude upsells using post__not_in but I already have a value and do not know how to combine the two.
I tried this:
'post__not_in' => get_upsell_ids(), [get_the_ID()]
But it is not ...
0
votes
0
answers
254
views
Save / Update meta data as multidimensional array
I need some help with saving my meta data from a post.
On the editpage I have the following input fields
<input type="text" name="data[color][]" value="red"/>
<...
0
votes
1
answer
279
views
get_the_terms, whether I should use string or array as the second parameter?
When I running Query Monitor on one of my page, I get a notice "Array to string conversion" for the following line:
$terms = get_the_terms( $post->ID , array( 'product-categories') )...