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
0answers
10 views

show just subcategory array

Looking to see if I can modify the below coding to pull just the category information. Currently at the category level it will pull all the products. Is it possible to just pull the subcategories ...
1
vote
1answer
539 views

Plugin settings page checkbox not saving - one options array with sub array

I'm driving myself crazy here trying to get a checkbox to save on a plugin settings page. Right now, as a template, I'm working through the excellent example given here: Settings API with arrays ...
0
votes
1answer
18 views

WordPress loop by meta key that is an array? and how loop multiple arrays

How can I get loop of posts by meta values that save in a meta_key that is an array like that $sharedHosting_plans_fields = Array ( ...
0
votes
1answer
26 views

Updata Metadata WP Rest API

I am trying to update a metadata I created from the front-end with a click event. { "id": 1248, . . . "metadata": { "wishlist_array": [ "" ], . . . ...
0
votes
0answers
11 views

Show the subcategory name based on current product

Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name. I just want to show subcategory name based on the product selected. I have one ...
0
votes
1answer
550 views

Get current user array with post string

I need to get 10 current user fields and pass the field values to a post string. The post string is expecting certain label names for each value. Example - post string expects 'firstname' => '...
1
vote
2answers
21 views

array_map() for sanitizing $_POST

I am working on an options panel for a plugin. And have an array being posted and updated to the options table. I am using the array_map() function to iterate over the array with sanitize_text_fields()...
0
votes
1answer
12 views

How to get user ID's from multiple usernames?

I am trying to produce user ID's from multiple specific usernames. The usernames are pulled from a profile field, and any number of usernames will be called. I want the user ID's from each of the ...
-1
votes
1answer
28 views

How to check if the postID is in an array? [closed]

In Wordpress, I am trying to check through an if else statement if the post is of a certain ID as follows: <?php if ($post->ID == array(224,222,583,645,203,11,639,228,226,230,634,615,625,214,...
0
votes
2answers
907 views

Removing a taxonomy term

There is a Wordpress function called wp_remove_object_terms that unfortunatly doesn't seem to work. I am trying to achieve the same ends using the following $post_terms = wp_get_object_terms( $...
0
votes
1answer
41 views

update_post_meta adding to array instead of replacing value

update_post_meta() keeps adding to an array instead of replacing value. Any tips? Previously I used add_post_meta() by accident and perhaps that somehow flagged the field as an array? Update So how ...
0
votes
1answer
16 views

Only show first image in foreach loop

My loop shows a list of values, and underneath them, the post title and image for the value. The problem is that because some values are associated with multiple posts, multiple images show up. I ...
0
votes
1answer
27 views

Array ids post to function have_post

I get as result of a main sql an array of post IDs, now what I need that Array of ids post to obtain the information and be presented in the following way: <?php $ids = [1,2,3,4,5]; // ...
-1
votes
1answer
26 views

Create heirachy of post terms from array & assign post to terms

I have a text string called $location_string which is an address in this format: 1 Victoria Street, Wellington, New Zealand as well as a custom hierarchical taxonomy called location. I am trying to ...
0
votes
1answer
664 views

how to remove/exclude html coding from json file while export?

I have created a file using json and exported it. Its creating HTML tags with it. Actually,I don't want to have that html part to be there in the file. Below I am sharing structure of my current file: ...
0
votes
1answer
669 views

Repeatable field within repeatable group of fields

Compounding on Saving metabox repeatable fields ... I've created a metabox with a series of fields that are repeatable. However, within those fields, I'd like to create another field named Choices ...
3
votes
1answer
1k views

How to update single value in multi dimensional Post Meta?

There are some values in Post Meta Data stored as a multi dimensional array. I want to update some of their data. Here is the Post Meta value displayed using <?php the_meta(); ?> voter: a:1:{s:...
0
votes
1answer
1k views

How do I use foreach to get content from a custom-field in multiple posts?

so I am trying to use a foreach to pull content from a custom field in multiple posts, but it just wont work. I can get it to work for a simple textarea string but I am struggling getting it to work ...
0
votes
1answer
31 views

Conditional multidimensional arrays and array_map

I'm using Roots Sage 9, which uses Laravel within WordPress, and am combining this with Advanced Custom Fields. For this, I have created a Controller, where I use an array_map to iterate through the ...
0
votes
0answers
22 views

AJAX call recieving a 400 bad request when array lenght is to long

I have a select dropdown where users can choose multiple options that get's sent to a custom Rest-API endpoint and returns values based on their selection(s). The dropdown is dynamically populated ...
0
votes
1answer
2k 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 ...
16
votes
5answers
12k views

WP Cron Doesn't Execute When Time Elapses

The goal I want to use wp_schedule_single_event( ) to execute a single event that sends me an e-mail 8 minutes after the user submits a form. The issue The following code is in my functions.php: ...
3
votes
3answers
853 views

WP doesn't show Array Custom Fields?

I'm wondering why WordPress doesn't list PHP array() and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can ...
1
vote
2answers
23 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
434 views

How can get all users by current user meta?

I have a block system to make users block each other, My question is how to get all users by current user meta by the array? When current user is blocked anther user it's saved as meta like this: a:1:...
0
votes
1answer
25 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
23 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
62 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
15 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
22 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
41 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
451 views

Pass a php string to a javascript variable

I need to pass a php string that is stored in $attr['footer_caption'] inside a shortcode function to a js file where the highcharts are initialized. $fields = array( array( '...
0
votes
2answers
21 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
61 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
28 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
473 views

Trouble with checked() for array of multiple checkboxes

I can't get the checked() to return what I expect. Data: Options: = array ( 'baseball' => 'Baseball', 'golf' => 'Golf', 'hockey' => 'Hockey', ) Values: = array ( 'baseball' => '...
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
42 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
18 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
33 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
24 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
46 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
22 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
19 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
35 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
40 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 ...
7
votes
6answers
12k views

Nice way to print_r arrays

So you know how Drupal has functions in modules like Devel that allow you to output arrays in a nice format like dsm($array) or krumo($array)... Does WordPress have an equivalent or a nice way of ...
2
votes
0answers
50 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
61 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&...