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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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
0answers
24 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 ...
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 ...
1
vote
0answers
135 views

Using Wishlist Member and I need to access a user's status

I am trying to create a default "Membership Alert" page, so if a user's membership has been cancelled, has expired, requires approval or requires confirmation I want to give them a message on this ...
1
vote
0answers
187 views

How do I dynamically generate args for wp_query?

I am trying to build up my search args depending on variables passed through from a form. What I want to do is add to args if values are present. For example if there are dates I have: $args = ...
1
vote
0answers
163 views

Storing a many to many post type relationship in post meta and keeping SQL ability for Joins

I have 2 Custom Post types and i am manually keeping a relation between them in a many to many relationship by keeping an array as a custom field. All PARENT post types have ONE filed in wp_postmeta ...
1
vote
0answers
10 views

Selecting and outputting results from DB with an array

I have always had issues with arrays. I can never seem to get them to work correctly. Could someone advise me. I want to make a selection from the database, use that in another selection and then ...
1
vote
0answers
38 views

Order char by post title

This is my code: $args = array( 'post_type' => 'post', 'orderby' => 'post_title', 'order' => 'DESC', 'posts_per_page' => 15, 'tax_query' => array( array( ...
1
vote
0answers
591 views

Sort alphabetically by custom field

I'm trying to change the sort order of a custom field in a custom post type. I want it to be be alphabetical by the 'location' name. It's sorting by location, but not keeping them in alphabetical ...
1
vote
0answers
113 views

Using shortcode to display array in array

I am using a widget, U more recent posts. Seems to work with custom taxonomies when you input the correct data into it in a widget form, but the suggested shortcode doesn't work (and I am trying to ...
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
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
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 ...
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
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
279 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
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 ...
0
votes
0answers
24 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
0answers
20 views

Removing duplicates from a merge of custom taxonomies

I'm trying to remove duplicates from a merged array. It has 4 custom taxonomies inside it. I already tried with 'array_unique' and with a regular PHP foreach. Here is the example with a regular ...
0
votes
0answers
17 views

wp-query loads forever when meta-key is missing

Im struggling with an query that should show posts in a date range given by advanced custom fields repeater date field. So my repeater fields have a start and end date: 24.05.2018 - 28.05.2018 01.06....
0
votes
0answers
104 views

tax_query order by custom array

I have custom array of post tag names ($arr_zips) which changes before every query. I managed to pull all posts containing the tag names and want it to additionally show posts from a category (...
0
votes
0answers
515 views

Featured image on archive page based on post type

Is it possible to use a custom featured image on the archive page? I created a secondary image space using the code below and would like the featured image to pull from that source vs the default '...
0
votes
0answers
114 views

Strange Behavior with update_option

If I run the following code in the debug console on my WP install, I get the expected behavior: <?php $option = get_option('fun_options'); var_dump($option); $new = array(); update_option('...
0
votes
0answers
125 views

Fatal error when using array_diff() function inside of wp_update_nav_menu hook?

I'm attempting to use the PHP native array_diff() function inside of a custom function that is attached to the wp_update_nav_menu hook: function my_nav_menus( $nav_menu_id ) { // .........stuff $...
0
votes
0answers
349 views

meta_query for user ID in array

I'm an attempting to query a meta value (array) of user IDs: $meta_query = [ [ 'key' => '_votes_round_2', 'value' => $current_user->ID, ...
0
votes
0answers
115 views

Cant get unique_array() work on get_the_category() foreach loop

i'm trying to list user's posted categories (main ones only) on the author.php I have prepared this loop but it has duplicated content <?php if ( have_posts() ) : while ( have_posts() ) : ...
0
votes
0answers
30 views

Trying to build custom breadcrumbs with tags slug if has_tag

I'm trying to build custom breadcrumbs using the tag's slugs, so to drive the people on pages and not on archives. I have two arrays, one for the tags corresponding to the name of regions and one for ...
0
votes
0answers
160 views

Adding more than one variable in this function

I would add more than one variable into the following function (for example 'referral_code', 'variable_2', 'variable_3') but I can't do it. Can anyone help me, please? Cheers! add_action( '...
0
votes
0answers
823 views

WP_Query: Meta_Query with serialized value (or a workaround)

I have a post type Issue, that has meta values in form of associative arrays (that are saved as serialized strings to database). They look somewhat similar to this: [article_reviews] => Array (...
0
votes
0answers
500 views

Display result from custom post meta query

This is driving me crazy! I'm trying to simply echo the contents of a meta field (twitter) from the wp_postmeta table of a custom post type with the following query outside of the loop : global wpdb;...
0
votes
0answers
93 views

Add custom filter to register data in array

I would like to register a multi arry of data in a plugin and allows any developper to add new value to the array. This multi array contains a name, and different value like this: class ...
0
votes
0answers
90 views

I am not getting result from php function that is json encoded

So I am trying to build an array of post data. But when I json encoded it I am not getting back the post object data from the database. Here are my two functions public function get_post_from_url(){...
0
votes
0answers
38 views

How to find the function which is outputting Array

I'm calling a plugin (Event Rocket) from a template and the output is mostly as expected but seldom the only thing that is displayed is "Array". I have consulted the plugin's makers and they have no ...
0
votes
0answers
550 views

Auto remove empty values in array

I have a custom meta box that let's users add new fields. If the fields are saved the values are stored in an array. If a user wants to delete a certain value he empties the field and saves the page ...
0
votes
0answers
43 views

When using an options array the Settings API isn't creating the database record

At the moment i am building my first plugin. So far i've saved as well as successfully uninstalled the options with single db records; everything worked like a charm. At the moment i try to improve ...
0
votes
0answers
86 views

wp_query - Modify $query to include duplicate content

I'm setting some featured content through the customizer (it's saved in theme_mod); Using the pre_get_posts hook, I'm retireving the feature pages in this way: add_action('pre_get_posts','...
0
votes
0answers
464 views

Fetching array of postmeta with $wpdb and in_array conditional

I'm trying to fetch an array of all entries to a specific meta key and then check to see if the user input value exists in that array. I've checked the data base for the query and I see the meta ...
0
votes
0answers
405 views

How to sort a WP_Query array by post_name after an array_merge();

I have an WP_Query array made up from two WP_Query() objects merged together as follows: $query1 = new WP_Query($args1); $query2 = new WP_Query($args2); $wp_query = new WP_Query(); $wp_query-&...
0
votes
0answers
92 views

Display a post based on its metabox selection

I created a client portal where a client can view their projects. I have two user accounts "Clients" and "Administrator. Both clients and administrator are redirected to the frontend of the site to a ...
0
votes
0answers
2k views

$wpdb->get_results in not an array

Using get_result I receive an "Invalid argument supplied for foreach()" because is not an array. I tried with get_col but I don't know how to extract the data and I don't know the difference between ...
0
votes
0answers
537 views

Wordpress WP_Query Array Custom search via taxonomies

I'm trying to write a custom search function for my WordPress site. I'm using WP_Query and multiple arraylists. Is it possible to order by search after taxonomy = pa_felg-bredde ? Here is my code ...
0
votes
0answers
1k views

Unserializeing multiple column values that are stored in one database results variable

Lately i have created a custom template to search for data in a database, and also displaying it, by the use of checkboxes. So, a user can select multiple checkboxes to search data on and the query ...
0
votes
0answers
727 views

Page doesn't load

I have following code, but my page doesn't load anymore. What is wrong? require( plugin_dir_path( __FILE__ ) . 'menu.php'); require_once( plugin_dir_path( __FILE__ ) . 'getuser.php'); add_action( '...
0
votes
0answers
464 views

Meta-Box to add multiple items one at a time and on publish save all

My example custom content type is for recipes. There will be a meta-box for ingredients. In this meta-box there will be three attributes and a "add" button. Name Measurements Notes Add Button My ...
0
votes
0answers
92 views

using array in wordpress database query

I have a strange situation, i'm working on wordpress website and creating a export plugin. On one page i have products name with checkbox and once i select few and submit it pass the value to next ...
0
votes
0answers
2k views

WP Query posts__in not working with array

I am using the following code to generate a specific list of posts with WP_Query $args = array ( 'post__in' => $cookie_array, 'post_type' => 'tyre', 'post_status' => '...
0
votes
0answers
234 views

File input returns null in theme options array

Trying to work out a rather complex array situation with a theme options page. While working with file upload I can't seem to get it to work. Any idea what I might be missing? Simplified example ...