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 ...

learn more… | top users | synonyms

0
votes
2answers
30 views

How do I disply an array inside a custom post type?

I tried to create a table output with the content of a custom post. I can echo my city properly: <span style="font-weight: bold;">city: </span> <?php echo get_post_meta($post->ID, '...
0
votes
1answer
5 views

WPML admin texts with serialized objects

I have been trying to get a plugin to work with WPML - I'm almost there but I'm wondering if anyone knows if it's possible to get WPML's admin texts (wpml-config.xml) to read serialized objects stored ...
0
votes
0answers
14 views

Run foreach loop again, e.g. when another parent category exists

I've been struggling with my breadcrumbs on a project I'm working on, I finally got the code to work using foreach loops to get the values I wanted and show a category_name and slug if needed. This ...
-2
votes
0answers
26 views

My website has an array error in a shop website [closed]

I am having a problem with a woocommerce shop website. I am currently getting: Warning: array_unique() expects parameter 1 to be array, null given in /home/coffeeom/public_html/test/wp-content/...
-3
votes
0answers
17 views

OOP help, how to implement custom lookup in my associative array within functions.php

I'm writing a function to execute on a custom action: //############## START OF NON WORKING CODE add_action( 'gform_pre_submission_1', 'myCustomFunction' ); function myCustomFunction( $form ...
1
vote
1answer
24 views

Script Localization doesn't work

I don't get how script localization works in wordpress. I created an associative array in php: $translations = array( 'value1' =>'This is first value', 'value2' =>'This is second ...
-1
votes
0answers
14 views

Problem in creating a new product with Woocommerce REST API

Below code is a sample code in WOO REST API documentation on how to create a simple product, but I think it has a bug in categories associative array. Could someone please clarify this? Is it ...
-1
votes
1answer
24 views

How to match data in multidimensional array of post_meta_data?

I am saving user id in post meta whenever someone clicks on like button. $voter = Array( voter => array( 'post_id' => $post_id, ...
-1
votes
0answers
9 views

Deleting one multidimensional array in options based on button click

I am trying to delete a specific options based on an button click. They are all displaced through a php foreach loop echo. Currently I have the delete working like this if (isset ($_POST['plugin-...
0
votes
0answers
3 views

is it possible to pass a multidimensional array via declaring it in a function? better just to declare it global? [migrated]

good afternoon, i've been trying to figure out build an array for use in multiple functions, inside functions.php. it appears that i need to create the array in its own function, and then refer to it ...
-1
votes
0answers
14 views

Can I save filtered WPDB queries to variables?

The long winded way would be to have lots of wpdb->get_results queries going on, but I'd like to make just one main call, as an array, and then create variables of filtered versions of the main ...
2
votes
2answers
33 views

Sorting list of sites from multisite network using wp_get_sites

I have a loop that pulls in all sites in my multisite site network and loops through them to get variables located in their ACF options. Here is an excerpt from the code I am using: $stageurl = ...
0
votes
2answers
12 views

Create an array with a string key from wpdb->get_results

Using this code to get some data into a PHP array: $currentProducts = array(); $currentProducts = $wpdb->get_results("SELECT id, feedid, size, price FROM products WHERE shopid = $shopid"); No ...
0
votes
2answers
31 views

Add key and value to an array in another file

In my site I'm using the Product Archive Customizer plugin for WooCommerce. Great plugin. However, there is an option to set the qty of products shown per page. The next piece of code is responsible ...
0
votes
1answer
22 views

saving data entered into a Metabox into an array? for use with for/each output.

good afternoon, followed this page to successfully add a Metabox field to my admin page, and now i'm trying to make it useful for me : https://paulund.co.uk/create-custom-meta-boxes i'm trying to ...
0
votes
1answer
32 views

Get css class of menu item in custom menu structure

So, I've created custom markup for a menu. The functionality of the menu is built like so... <?php $parent = array(); if (($locations = get_nav_menu_locations()) && isset($locations[...
1
vote
1answer
28 views

Adding an array from a query string to a WP meta_query

I am collecting values from a query string as an array. Then collecting those values and placing them into the value of the 'meta_query'. I am having trouble where nothing gets outputted from the ...
3
votes
2answers
50 views

How do I output a database option that is an array into a get_posts array?

This must be fairly simple, but I'm puzzled. And I may be going about it backwards. How do I output a database option that is an array into a get_posts array? I have an option in the database that ...
1
vote
2answers
80 views

meta_query key value from array

I have a custom post type called 'game' with some ACF fields. One of the fields is a Post Object(called review_link) that accepts posts from a category called 'reviews'. One other field is a taxonomy ...
0
votes
1answer
29 views

Changing a specific value inside a complex repeater/flexible content field (ACF)

So I have a really complex ACF repeater / flexible content field (essentially a pagebuilder). What I want to do is get a specific sub-sub-subfield value from one post ($source_post) and insert it in ...
0
votes
1answer
34 views

How to display checkbox meta array values one by one?

By wp user frontend I add some checkboxes to users frontend profile. When I use echo get_the_author_meta('my_pet', $author_id) output is: cat| dog| hamster And when I use this loop code $pet = ...
1
vote
3answers
35 views

How to fetch an array in $wpdb?

I have a snippet that will select a data from database table. But I encounter an error: Warning: Invalid argument supplied for foreach() I encounter a new error: Notice: Trying to get property of non-...
0
votes
0answers
27 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 ...
0
votes
1answer
12 views

Recent posts with featured image or fallback image with permalink

In my sidebar.php I have some code that prints the recent comments. I could not share the complete code here because of the formating restrictions. You can find the code here: https://codeshare.io/...
0
votes
0answers
12 views

compare database values before an update

in my wordpress, I want to store my form data to database by using: update_user_meta(); I successfully store the data to database and write it to the page, but the problem in whenever I updated the ...
0
votes
1answer
49 views

WP Meta Query for some meta (array) values

If I get my posts using meta_query by 'my_meta_key' only I get something like this Array( [0] => Array( [nested_key1] => something_I_want1 [nested_key2] => ...
0
votes
0answers
39 views

How to use get_stylesheet_directory_uri() in an array?

I create an social icon placeholder on the WordPress theme. I am using this code: "url" => get_stylesheet_directory_uri() . "/images/rss.png" to placed a default icon. I's work on old WP ...
1
vote
1answer
61 views

Query all posts if multiple meta key don't exist

I'm trying to get all posts that don't have a meta ket that starts with aa_. I can do it this way $args = array( 'posts_per_page' => -1, 'category__in' => 23, 'meta_query' => array( '...
0
votes
1answer
29 views

Merge arrays and order set and subset as one

I have two arrays that filter and order posts by two different custom keys. What I need to do is to merge the arrays and order them by their own custom keys, to not have first a list of the array a ...
0
votes
0answers
8 views

Book-like index on a page with foreach custom field and array merge

I'm trying to make a page with a Table of Contents in which my 'lyric' posts need to be ordered by three different custom fields. Basically each song could either be Original or about a Game, and in ...
4
votes
2answers
51 views

Building a scalable Wordpress favouriting plugin - one serialised meta value array or many meta records

I am trying to build a simple Wordpress favourite post plugin that is scalable and could handle 1000s or 10000s of users or more. There are several different approaches that I have seen in other ...
0
votes
1answer
28 views

List users of specific role instead of removing them with specific role

I am currently listing all the users except users with administrator role on custom page template with: <?php $allUsers = get_users('orderby=post_count&order=DESC'); $users = array(); ...
0
votes
3answers
47 views

Plugin Options Array Set to Undefined

I want to set a number of plugin options set to blank if they are not defined so I can avoid the PHP notices. What is a better way of writing this code? $options = get_option('plugin_options'); // ...
0
votes
1answer
49 views

Replace text inside a huge multidimensional array

I've a huge multidimensional array with no-way to foreach it :), Anyway, i want to replace all http to a keyword so if the client convert his website into https he won't change all old images for the ...
1
vote
1answer
62 views

Use pre_get_posts to sort meta_key by an array of values

Scenario: I have a bunch of resellers loaded under a "reseller" post type. Each of these resellers have a "rating" which is a string value like Gold, Bronze, Silver - this indicates their status as a ...
0
votes
1answer
97 views

update_post_meta from data in multidimensional array created from a form

So, I have a few form fields like so: <input name='mainStageSatOrder[theband][theid]' type='hidden' class='band-id' value='' />"; <input name='mainStageSatOrder[theband][theorder]' type='...
0
votes
1answer
39 views

WP Query for variable taxonomies

I am stuck with this. Maybe its simple, maybe its not. But there goes. I understand that the standard way of querying multiple taxonomies in wordpress is using the method described here. https://...
0
votes
1answer
82 views

Get the correct meta_value with get_post_meta

I tried using the function get_post_meta() to get the meta values of my posts. However to my surprise it returns an Array that contains again arrays! So I looked inside the second level array, and was ...
0
votes
1answer
223 views

Get a list of ACF Repeater-Fields as array

I run a Site for a concert & music club. Events are set within a custom post type called "events". In this i set the date, the name of the event and all other infos about that event. In this ...
0
votes
1answer
27 views

WP Page Options Array

I'm creating a page options which contain some multiple checkboxes with specific values. Here is a snippet of my checkboxes form code: <label>Global Checkboxes</label> <input ...
1
vote
0answers
8 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
1answer
93 views

Admin Options page. Save as Array

I'm not great with PHP. I've just created a WordPress admin options page and it works OK: // Admin Menu add_action('admin_menu', 'my_cool_plugin_create_menu'); function my_cool_plugin_create_menu() { ...
1
vote
2answers
345 views

Call global variable array() in woocommerce child/template

So I have this in my functions file - it defines the products that are not eligible for free shipping. It works everything is fine. //functions.php function my_free_shipping( $is_available ) { ...
1
vote
1answer
34 views

Struggling with array and foreach loop

I have a function that outputs an array with 2 objects(?): Array ( [de] => 166 [it] => 167 ) Where [xx] is de language code and the number is the pageID. I'm having a meltdown in my brain as I ...
1
vote
1answer
150 views

Update post meta does not serialize array

For some reason my update_post_meta() function does not accept an array. Normally the function serializes the array by itself, but now I need to do this by myself, otherwise it does not update. Could ...
1
vote
0answers
26 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( ...
0
votes
1answer
53 views

Dynamically adding filters

I have a function that I'm trying to get an array in it to use in a callback to dynamically add filters. Here is the function that I need to retrieve the array keys from ( in the $classes variable ): ...
2
votes
2answers
135 views

List of posts by day of the week

I have Radio with programs and they are associated to day of the weak. Example: 1-Program Disco Nights plays at Monday and Friday 2-Pragram Crazy weekends play only at Sunday 3-etc 4-etc ...
0
votes
1answer
195 views

How to use json_decode a post_meta value? [duplicate]

I have used get_post_meta($post->ID) to get all custom fields for my post since I have many of htem. Some of them were checkbox values and var_dumping the variable gives me this array (size=1) 0 =&...
0
votes
1answer
34 views

Plugin Shortcode value in post

Theme was output with function get_post_meta(get_the_ID(), 'some_value', true); when I try with die(print_r()); function there have some array containing values such as [item_ticket_tailor] => ...