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.

Filter by
Sorted by
Tagged with
0
votes
1answer
16 views

Remove empty terms from array, sort alphabetically, update back to repeating field

I have a repeating field that stores text terms in an array, like this: [0] => [1] => NUC Lights [2] => Smoke Alarm [3] => Binoculars You'll note key A has no value, and they're not ...
0
votes
1answer
32 views

Loop through ACF multi array [closed]

Please excuse my code example, but I am trying to loop through multiple arrays of an ACF sub field object. I want to display all sub fields from a custom field group by section (so section 1 first, ...
0
votes
0answers
23 views

Pass an argument into a function to extract from array

I feel like this should be possible. I have a function within my class which pulls a single row from my custom table: class Get_Data{ public static function get_data_single_db() { ...
0
votes
0answers
15 views

How to make this custom capability work? [duplicate]

I am trying to make a custom ability on my page CV people can insert and then view their CV I made a custom capability view_cv and I want for it to remove the option to view their CV. <a class="...
0
votes
0answers
13 views

How to get an array from the plugin User Role Editor? [closed]

I installed this plugin called User Role Editor and put up a bunch of custom capabilities like(for example view_page and I want to write that if this is true then that user can view that page), now I ...
0
votes
0answers
14 views

Get all the Tags Assigned to Current User

I am looking to find a way to get all the user_tags. I have 3 Tags applied to the current logged in user I just want to simply get the tags as an array. Something like this: $user_tag = array('29GA ...
0
votes
2answers
22 views

adding additional class to get the post thumbnail [duplicate]

I'm just starting to create new theme and i'm new to code. I'm stuck in customizing the post thumbnail code, i tried add <?php previous_post_link(get_the_post_thumbnail(get_previous_post(), array(...
0
votes
0answers
32 views

Array merging multiple get_posts throwing Undefined offset error

Good morning. I've been trying to create a related posts function. The broad idea being; the user can manually select related posts using an ACF relationship drag and drop interface, but if they don't ...
0
votes
1answer
22 views

Replace an array (with identical values) with another array in the_content

I'm making a plugin where I need to edit the H2 tags in the post content. I've been at it for two days, but my php knowledge is too limited to solve the issue.. What I want to achieve is to return ...
0
votes
0answers
10 views

show just subcategory array

Looking to see if I can modify the below coding to pull just the category information. Currently at the category level it will pull all the products. Is it possible to just pull the subcategories ...
0
votes
1answer
21 views

WordPress loop by meta key that is an array? and how loop multiple arrays

How can I get loop of posts by meta values that save in a meta_key that is an array like that $sharedHosting_plans_fields = Array ( ...
0
votes
0answers
11 views

Show the subcategory name based on current product

Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name. I just want to show subcategory name based on the product selected. I have one ...
0
votes
1answer
33 views

Updata Metadata WP Rest API

I am trying to update a metadata I created from the front-end with a click event. { "id": 1248, . . . "metadata": { "wishlist_array": [ "" ], . . . ...
1
vote
2answers
27 views

array_map() for sanitizing $_POST

I am working on an options panel for a plugin. And have an array being posted and updated to the options table. I am using the array_map() function to iterate over the array with sanitize_text_fields()...
0
votes
1answer
14 views

How to get user ID's from multiple usernames?

I am trying to produce user ID's from multiple specific usernames. The usernames are pulled from a profile field, and any number of usernames will be called. I want the user ID's from each of the ...
-1
votes
1answer
29 views

How to check if the postID is in an array? [closed]

In Wordpress, I am trying to check through an if else statement if the post is of a certain ID as follows: <?php if ($post->ID == array(224,222,583,645,203,11,639,228,226,230,634,615,625,214,...
0
votes
1answer
44 views

update_post_meta adding to array instead of replacing value

update_post_meta() keeps adding to an array instead of replacing value. Any tips? Previously I used add_post_meta() by accident and perhaps that somehow flagged the field as an array? Update So how ...
0
votes
1answer
73 views

Only show first image in foreach loop

My loop shows a list of values, and underneath them, the post title and image for the value. The problem is that because some values are associated with multiple posts, multiple images show up. I ...
0
votes
1answer
28 views

Array ids post to function have_post

I get as result of a main sql an array of post IDs, now what I need that Array of ids post to obtain the information and be presented in the following way: <?php $ids = [1,2,3,4,5]; // ...
-1
votes
1answer
26 views

Create heirachy of post terms from array & assign post to terms

I have a text string called $location_string which is an address in this format: 1 Victoria Street, Wellington, New Zealand as well as a custom hierarchical taxonomy called location. I am trying to ...
0
votes
1answer
49 views

Conditional multidimensional arrays and array_map

I'm using Roots Sage 9, which uses Laravel within WordPress, and am combining this with Advanced Custom Fields. For this, I have created a Controller, where I use an array_map to iterate through the ...
0
votes
0answers
25 views

AJAX call recieving a 400 bad request when array lenght is to long

I have a select dropdown where users can choose multiple options that get's sent to a custom Rest-API endpoint and returns values based on their selection(s). The dropdown is dynamically populated ...
1
vote
2answers
27 views

Only a part of array is stored in transient – what could be causing this?

I have created an autosuggest array that I want to store in a transient. My code looks like this: <?php // Get any existing copy of our transient data $suggest = get_transient('suggest'); if ( ...
0
votes
1answer
28 views

Add to array, redirect and display

I want add text to array and display after redirect and unset array. class test{ public function one(){ $this->save(2, 'some'); $url = get_site_url(null, '/redirect_to_two');...
2
votes
1answer
30 views

Generate an array of parent/child page IDs, based on parent page name

I've been using the following functions (updating IDs manually) to group parent & child pages into an array, which I then use in an if/else statement to present content depending on whether or not ...
0
votes
1answer
92 views

Wordpress meta query with meta serialized data array value

Looking for a method to nest AND/OR relation in meta_query based on array serialized values. Reviewed these already: Query multiple meta key values? WP Meta Query for some meta (array) values I ...
0
votes
2answers
17 views

Get an array wich contains the post_name of every post that has the custom post_type “pelicula”

I need an array that contains all the posts names that match with the post_type"pelicula"
0
votes
1answer
24 views

Combine multiple menus using the filter wp_nav_menu_items

Is there a way to combine multiple menus in the functions.php file using wp_nav_menu_items()? I need to hook in a second menu to the main menu. The site has two separate menus in the header. One is a ...
0
votes
0answers
50 views

How to filter specific element of an array in wordpress/php?

I have a php code as shown below in which I have added Line#A for the debugging purpose. <div class="vidlist-main__meta cf"> <?php //if ( has_excerpt() ) {the_excerpt();} $tags =...
0
votes
2answers
27 views

Help using an array in 'exclude' key of another array

I want to exclude two items (using their IDs) from an array that's retrieving images attached to the post: the post's thumbnail (featured image) and an image attached via Advanced Custom Fields. I'm ...
1
vote
1answer
98 views

Using a variable in is_page(array())

Similarly to this topic I need to extract some page IDs from user input (a theme options admin page), store them in a variable, and then filter using the is_page() filter. The input consists of ...
0
votes
1answer
28 views

Add Array record to Meta Post

I am trying to add the following array into the meta post table "a:2:{s:11:"target";a:1:{i:0;a:1:{i:1;a:3:{s:5:"param";s:13:"page_selected";s:8:"operator";s:2:"==";s:5:"value";a:5:{i:3001;s:13:"...
0
votes
1answer
20 views

I want to place a post before all others from an ACF boleen field

I am currently trying to retrieve an post (to put it before all others in the search results of a search filter I created) from an ACF boolean field (and I am a beginner), so I made this script but I ...
1
vote
0answers
56 views

call_user_func_array() error in class-wp-hook.php

I have this message when I try to add a new variation of a product on Woocommerce/WP: Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two ...
0
votes
1answer
22 views

Reading Content in an Array as it relates to a meta_query

I am capturing a user's Work Anniversary and their content is being stored in an array. So the key as it relates to these Meta Fields is hire_date and the value that is stored in that array looks ...
0
votes
0answers
33 views

How do I save values from a foreach output on an options page?

I am creating a plugin that outputs a metabox on each page to be able to assign custom meta descriptions plus some other values. All of that works perfectly. However, I also have a "bulk editor" ...
0
votes
0answers
24 views

How can I stop an custom field value from appearing in a dropdown list

I have a dropdown field that displays custom values that I can add from the admin portal. I would like to exclude an option called 'Meal' so it does not show in the dropdown field on the frontend The ...
0
votes
0answers
47 views

Convert number to date format within an array

I have a custom field of deal_date that I need to work into an array. When using directly on a template I can just set the output format directly in the ACF UI. However I obviously cant use get_field ...
0
votes
1answer
22 views

meta query or with meta value

within one of my query_posts I use 'meta_key' => 'clpr_topcoupon', ;meta_value'=> 1, now I would like to show post without as well but the one with meta_value first. I tried: 'meta_query' => ...
0
votes
0answers
19 views

Save post meta save as multi dimensional array

I want to make portfolio page using meta field, where clicking to image opening image slideshows. So I want to loop main clickable image in array and images of slideshow as an array of main image, ...
0
votes
0answers
42 views

WP post meta - for loop inside for loop

I wanna make a portfolio on-click opening images gallery using meta fields. So firstly I make array of portfolio images and loop them. Then I loop gallery images of every portfolio item, but it loops ...
0
votes
0answers
44 views

Staggering featured post using 'sticky'

So I have Custom post type that occasionally will have posts marked as 'featured' Client would like to use the 'sticky' feature of WordPress to pick which posts from the CPT are classed as featured ...
2
votes
0answers
54 views

Can an array be used as a meta_query value?

I'm trying to query a custom post type (courses) by grade using WP_Query and Advanced Custom Fields (ACF). Grades (checkboxes) are organized by term (groups). Four grades per term, four terms per ...
0
votes
2answers
66 views

How should I identify the inline javascript that is the dependent of a wp_enqueue_script?

I want to run my own JavaScript on a specific WordPress page but only after a third party's plugin runs as I am trying to slightly modify that plugin. My problem is that my JavaScript is running ...
0
votes
0answers
11 views

sql query for selecting btween two amounts

I am trying to achieve the result by selecting dropdown between two amount range. echo '<option value="browse-events?city='.$browse_city.'&type='.$browse_type.'&price=Free">Free</...
0
votes
1answer
31 views

How to output get_tags array list to select box

I have a custom meta box. In it there are input fields, as well as a select box. What I want, is to have the get_tags array list to be outputted as the values in the select box. I currently have the ...
0
votes
1answer
61 views

How to avoid duplicate users when I am using get_users?

I using get_users to get users from my database. I am using this code: $args = array ( 'role' => 'Colaborador', 'role__not_in' =>[ 'subscriber', 'Administrator'], ...
0
votes
1answer
371 views

Remove duplicates - array_unique()

I am trying to make a simple list of names that link to profile information. Some of the people in the list have multiple addresses and therefore appear multiple times in the list (as their addresses ...
0
votes
1answer
15 views

How can I get all values from my array in a loop in php? [closed]

I've following array: Array ( [0] => Array ( [0] => 585 [1] => 596 ) ) Now I want to print all values (585 & 595 .....) row for row in a ...
0
votes
1answer
86 views

get_category_parents to array

Ok, So I get a choice from a wp-dropdown. This choice is a category. I use this category to find it's parents. This seem to be outputting a string. This string should be converted into an array. And ...