Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
2answers
16 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
25 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
0answers
12 views

Python refer each JSON element in an array [migrated]

I have an array of JSON objects as follows. How do I parse each JSON object from the array? For example, I want to parse {"occurrences":"1","post_title":"Test 5","ID":"16"} and send it as body to an ...
0
votes
1answer
23 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
19 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
21 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
16 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
31 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
23 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
24 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
21 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
15 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
29 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
30 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 ...
1
vote
0answers
38 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
43 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
9 views

sql query for selecting btween two amounts

I am trying to achieve result by selecting dropdown between two amount range. echo '<option value="browse-events?city='.$browse_city.'&type='.$browse_type.'&price=Free">Free</option&...
0
votes
1answer
18 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
29 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
142 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
13 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
39 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 ...
0
votes
0answers
23 views

How to add each letter, entity, special character from post title to array

I try to add each letter, entity, special character from post title to array but quote symbols not working. I use this function in the loop and single post page. Entities are in the numeric HTML ...
0
votes
0answers
252 views

Notice : Array to string conversion on array_intersect user meta

I am trying to check if two meta data has any common array values. Its returning an error Notice: Array to string conversion in functions.php on line 1026 which is $inbox = count(array_intersect($...
0
votes
1answer
25 views

Remove a link from a page ID used within an array [closed]

I've the code as below: <div class="row"> <?php $pages = array(54,55,56,57,58,74,75,76,77,78); $i = 1; foreach ($pages as $page) { ...
1
vote
1answer
53 views

PHP Array Returning [object Object]. Tried existing answers results with no luck

I have tried multiple solutions that I have found around and none seem to be working. Can anyone give me any help? I want the result to return the ID's ($user) and currently it returns [object Object] ...
0
votes
2answers
122 views

Combine multiple queries, array_unique returns nothing

I'm combining multiple queries for a loop using the following method: function order_by_date( $a, $b ) { return strcmp( $b->post_date, $a->post_date ); } // get the posts for the first ...
0
votes
2answers
36 views

How to print array of specific item

I have get the following array from my database using mysql query in PHP. What is way to print the specific item (e.g: staff_name and coupon)? {"items":[{"ca_id":1,"appointment_date":"2018-07-02 08:...
0
votes
2answers
67 views

(Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array

I'm developing a system where I have a Deck presentation. I have a field that takes the post by the 'copas' type of card being within the 'meta_value' array specification, and I would like it to be ...
0
votes
2answers
241 views

Store custom field's multiple values in one user meta key

I've added some custom fields into the user profile. It's "Date of Birth". There are "month_of_birth", "day_of_birth", "year_of_birth". How to store them in one meta key ('birth_date') ? Here's the ...
0
votes
1answer
31 views

Getting posts to exclude from array

I have an array, where keys are the post ID's and values are post titles. $options = []; $args = array( 'posts_per_page' => -1, 'fields' => '', ); $posts = get_posts( $args ...
0
votes
3answers
58 views

Get all posts as an array ID => Name

I need to query all of my posts as an array in example: 'options' => [ 'Post ID' => __('Post Name'), 'Post ID' => __('Post Name'), ], How can i do it? tried this but it gives me ...
3
votes
3answers
99 views

Getting an array out of WPQuery

I have a query like this i will get the id's for product. This works fine: function ids(){ $args = array( 'numberposts' => -1, 'post_type' => 'product', '...
2
votes
1answer
185 views

How to query serialized array by comparing greater than (>=)?

I have serialized post meta values. It looks like this: In array: $kisiArray = array( 'option1' => 7, 'option2' => 'bar', 'option3' => 'apple', 'option4' => 'orange' ); And ...
1
vote
1answer
245 views

How to update serialized post meta?

I have serialized post meta. And i want to update single meta key. It looks like this: In array: $kisiArray = array( 'option1' => 'foo', 'option2' => 'bar', 'option3' => 'apple', ...
0
votes
1answer
141 views

How to display line breaked meta values in table?

I have meta_key 'oyuncular' and it has meta values with line breaks. I want to get them and display in table with two column. Name and Role Name $names = get_post_meta( get_the_ID(), 'oyuncular', ...
0
votes
1answer
164 views

How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…\wp-includes\class-wp-hook.php on line 286

I am creating Wordpress Dashboard Menu: add_action('admin_menu', 'personalised_menu'); function personalised_menu() { add_menu_page( 'Page Title' , 'Blog' , '...
4
votes
1answer
81 views

How to build widget with arrays inside arrays?

I've started building a widget that needs to have an array inside an array. I'm trying to get the widget to have the ability to create multiple elements that will display on the site, but also has ...
1
vote
1answer
140 views

How to list custom fields as headers and list all pages sharing that custom field under it?

I'm trying to use a custom field of "State" to list all the city pages for available locations. I'm able to get the right results, in the (alphabetical by state) right order with this code: <?php ...
1
vote
1answer
47 views

Add multiple tags to multiple posts

I have an array of posts IDs like this: $id_post_array_full=array(239,243,246,248,250,252,255,257) I would like to add tags for each posts with this function of wordpress wp_set_post_tags(). My real ...
0
votes
2answers
650 views

how to get post order by post id wp_query?

i have 4 post and i displaying 2 post per page. $ids = array('16085','16088','16083','16091'); $options = array( 'post_type' => $post_type, 'posts_per_page' => $posts_per_page, ...
1
vote
1answer
56 views

foreach loop still echoes array

I'm not sure why the foreach loop is still printing an array for my $education variable. This code is supposed to get the custom post fields. It works with the title, the image and the about variable, ...
0
votes
1answer
48 views

Repeat array inside array through while loop

I want to repeat this array: array( 'taxonomy' => $tax, 'field' => 'slug', 'terms' => $cat, ) because I am getting the value of taxonomy and categories from custom sub ...
0
votes
0answers
25 views

how to check meta value as a multi array in wordpress query?

I have property listing on my page. i have to do filter on my page if user enter property guest value 5 then i need to fetch only that post where guest value is 5 that store in post meta value as a ...
0
votes
2answers
46 views

restrict current user from receiving email using wp_mail

I have create a code through which current user can add other users in his project. These users are only shown on the project page. They will not have any right to modify the project. Once these ...
0
votes
1answer
196 views

update_post_meta() with a modified array?

When in wp-admin I want to manipulate one value of an array and then update the post_meta with this array. My array looks like this: 1285 array(1) { [0]=> array(2) { ["description"]=> ...
-1
votes
1answer
18 views

PHP Use Declared array Variable inside already Declared Array

i have created one class in which i declared public associative array. class test{ public $basicCols= array( array('title'=>'KEY', 'field'=>'slug','options'=>$optList), array('...
0
votes
1answer
48 views

Matching slug terms from one array to those in array of WP_Term objects to output term names

I'm using WordPress's get_terms to return an array of WP_Term objects containing the term_id, name, slug, etc. for the child terms of a given taxonomy. I've saved this array to $tax_terms. I have a ...
0
votes
2answers
121 views

How can I add multiple 'tax_query' arrays via a loop?

I'm trying to build functionality (using the Advanced Custom Fields plugin) to list information in a page template for all custom post types ('Product') that have specified taxonomies. This is my ...
1
vote
1answer
108 views

How can I pick a single post from the latest 3?

I'm looking to display a single featured post from my latest 3 posts at random. I've managed to get it up and running picking any post at random just fine, but I want to filter it down to only the ...