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
0answers
26 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
359 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
55 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
231 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
39 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
85 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
525 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
38 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
77 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
103 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
344 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
605 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
142 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
216 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
97 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
74 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
1k 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
69 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
54 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
2answers
48 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
306 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
19 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
58 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
239 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
112 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 ...
0
votes
0answers
26 views

Remove item from post_meta array via AJAX

I have a form on a page where users can add new text inputs (up to 30 inputs). The entered value of this text input is stored in the post_meta table via AJAX as an array. Here is the php that ...
0
votes
1answer
123 views

change order of images attached to post

Im not quite sure how to explain my issue so let me know if Im unclear about anything. I have on my front-end post form a multiple file upload input that uploads files to my specified folder and ...
0
votes
1answer
28 views

Is there a way to add a new value into a stored custom field value?

I am trying to save some numbers into the posts as a custom field in different times. I want to store an array that includes selected numbers for each posts. But I can't update the current values (...
0
votes
1answer
970 views

Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Wppr_Public' does not have a method 'amp_support'

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Wppr_Public' does not have a method 'amp_support' in /home1/thrfolde/public_html/3foldtraining/wp-includes/class-...
0
votes
1answer
149 views

Make sticky post with FacetWP

I have WordPress posts in combination with Advanced Custom Fields and FacetWP for filtering. WordPress has an option to make a post sticky, I did this and nothing happenend so I tried to change my ...
0
votes
1answer
108 views

WordPress i18n in Array throws Error

i am wirting my very first plugin. For publishing it to the repository i want to make it translatable. On my options page i some arrays, which store the default settings. Somehow i get an error when ...
0
votes
1answer
21 views

Add first letter of titles to array, then compare arrays

I have a custom post called foundation_firms, from which I'd like to create an array of letters, each letter representing that there exists a post starting with that letter. I've been trying to use ...
0
votes
1answer
57 views

Trouble with calling an imploded variable in an array

I'm having trouble with calling an imploded variable that is then formed to an array and called in a post loop argument. $user_id = um_profile_id(); // Get current user ID $...
1
vote
1answer
237 views

var is undefined in a Gutenberg block

I'm fiddling with Gutenberg right now and I'm stuck trying to build a dynamic block. This is the code I'm using (some code is omitted for clarity): registerBlockType( 'my/block', { title: __( 'My ...
0
votes
1answer
27 views

I'm unable to call img path using single quotes in an array?

I would like to call an image next to input field in wp comment form. But I'm unable to do that. I call image when '' <= single quotes doesn't exist. But I don't know how to call an image in single ...
0
votes
1answer
61 views

Print specific values stored in a post meta array

I'm triing to print some values stored in a post meta. My post meta_values looks like this : a:3:{s:6:"amount";s:117:"€2.00";s:6:"entity";s:5:"11854";s:9:"reference";s:9:"800146779";} I'm ...
0
votes
1answer
32 views

Multiple meta key and value search in the query

I am have this following API code for $_REQUEST $metakey = explode(',',$wpdb->escape($_REQUEST['key']) ); $metavalue = explode(',',$wpdb->escape($_REQUEST['value']) ); $meta = ...
0
votes
1answer
2k views

Plugin Error array_key_exists(): The first argument should be either a string or an integer [closed]

Checking the Query Monitor its throwing out this error: array_key_exists(): The first argument should be either a string or an integer - which relates to this function: public function ...
1
vote
1answer
863 views

Get posts id in array by meta value and key

How to get all posts ids that has a meta key and value. $meta_key = 'hide_rss'; $meta_value = 'yes'; $post_ids = array(1, 2, 3);
1
vote
2answers
3k views

Check if term object is in array

I want to check if a term object is in an get_terms array, but i really can't figure out how to do it. $subcat_terms = get_terms([ 'taxonomy' => 'product_cat' ]); $subcat_terms generates an ...
0
votes
1answer
113 views

Orderby post__in Not Working Correctly?

I've created an array based on the numerical values of an object. After which I removed everything in the object in the array, except for the ID. So it ends up looking like this: [115, 123, 66, 64] ...
0
votes
1answer
53 views

How add a custom posttype name using ACF field to a query post array

I'm loading custom post type to different pages by changing cat id and sometimes post type name query_posts(array( 'post_type' => 'posttype_name','posts_per_page'=>-1, 'tax_query' => array( ...
0
votes
2answers
158 views

How can I access string value in an array?

currently I am developing a site using the Dokan multivendor plugin. I added a custom field in the registration form and The below code is being used to add the custom field in the registration form ...
0
votes
1answer
590 views

get_terms() returns Trying to get property of non-object error for custom taxonomy

Created custom post type and now I'm trying to create a custom taxonomy. Once I create it and try to access it with get_terms() I get an error of non-object. Var_dump is giving me an empty array ...
1
vote
1answer
36 views

How to add day number and initial to my post graph?

I have been building this recent-post-count dashboard widget graph - or, more accurately, modifying and refining a comment-specific version, for posts. I'm really pleased. Some of it may be ...
2
votes
1answer
46 views

Get (echo) all role names assigned to user

Im trying to do something which I feel should be quite easy but I can't seem to quite grasp. I have the below code which echo's users roles. Great. Fantastic. BUT I have a problem when a user is ...
1
vote
1answer
221 views

Modify foreach loop for social sharing links?

How would I amend the following foreach loop so each link displays the keys from each nested query, and not just the values? I am creating my own social sharing links, included using get-template-part,...
0
votes
1answer
832 views

Too slow when using both 'tax_query' and 'meta_query' both in WP_Query

I have added the full array in end of the post. I have passed 'post_type', 'posts_per_page', 'tax_query' and 'meta_query' for WP_Query. This page take around 10 - 15 seconds to load... It is too much ...