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.

1
vote
2answers
22 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
24 views

Add to array, redirect and display

I want add text to array and display after redirect and unset array. public function save($type, $value){ global $tab; $tab[] = array('type' => $type, 'value' => $...
2
votes
1answer
18 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
10 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
13 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
20 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
36 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
18 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
31 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
24 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
27 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
17 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
32 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
28 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
32 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
33 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
44 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
44 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
20 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
35 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
183 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
49 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
281 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
146 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
70 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
307 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
34 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
59 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
100 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
203 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
300 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
177 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
84 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
49 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
755 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
57 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
26 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 ...