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
1answer
43 views

WordPress Query Returning Every Post

I have a custom WP query that searches a single custom field, using an array. The custom field is for the country of origin of a post. The array I'm using are the names of the various countries in a ...
0
votes
3answers
88 views

Creating Custom Query

I've hit some sort of stumbling bock here, and I can't find my way over it. I'm trying to craft a custom WP query that searches for posts by country of origin, selecting multiple countries at once. ...
1
vote
1answer
432 views

How to save array of datas in option page by setting api?

I am trying to create my own first plugin but I am coding novice so please guide me to the right direction. This plugin is to set the post expiry date based on the user's role. Now I am stuck at ...
4
votes
1answer
630 views

Insert new element to array with add_filter

add_filter('example_filter', function(){ return array( 'tax1' ); } ); add_filter('example_filter', function(){ return array( 'tax2' ); } ); add_filter('example_filter', function(){ return array( ...
0
votes
1answer
55 views

Organizing and grouping an array by year

looking for some code review. I had an issue where I had to list events by their year. This was sorted by a meta_key ( "show_date" ). It works as intended, though I'm interested to see if there is ...
2
votes
1answer
179 views

Sort a custom post type array numerically

We've set up drop down lists to allow people to filter posts based on custom post types. In order to populate the drop down list I am using: <?php $terms = get_terms("ratios"); $count = ...
0
votes
1answer
124 views

Error while setting role

I already got code which can change role basis on post count. <?php add_action( 'save_post', 'update_roles' ); function update_roles( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) ...
0
votes
1answer
527 views

Get categories names as an array to use it in theme settings

I am building a theme and for the Theme Settings Page I followed this tutorial: http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/ What I want now is to have ...
0
votes
1answer
571 views

orderby not working for query_posts using array of IDs

I have an array of IDs that i send to query_posts to get the posts (which works fine) but it seems to always put the attachment(562) last even though it is the newest. Also tried title and ASC vs DESC ...
0
votes
2answers
2k views

Query posts using custom taxonomy and selected terms

I'm not able to use array for the terms in the following query, only a single term: $args=array( 'facts' => 'information', //taxonomy:facts and term:information 'post_type' => ...
-2
votes
1answer
365 views

How to define category ID in an array?

I have the following: <?php if ( array( 'is_category', 'is_tag' ) ) { ?> What I want to do is (that doesn't quite work): <?php if ( array( 'is_category('13')', 'is_tag' ) ) { ?> So ...
0
votes
1answer
477 views

Listing all posts from current category on page

I'm trying to list all posts from a certain category, in a list, on the category page that already lists the posts out in blog form. I'm trying to do it in the header area so that you can get an ...
0
votes
1answer
2k views

Retrieving multiple values to the Post Meta (using an array)

I'm having a problem retrieving post_meta values that I have stored in an array. I use this for storing the array: add_action( 'comment_post', 'add_food', 1 ); function add_food(){ global $post; ...
0
votes
2answers
93 views

How to randomise my menu items?

So I thought I could do it like this (also I want to only get 3) - $menu_items = wp_get_nav_menu_items(26); $menu_items = array_rand($menu_items, 3); foreach ( (array) $menu_items as $key => ...
0
votes
1answer
60 views

Output comment_author in array

In functions.php for part of custom comments, I have the following echoed array as the link to respond to a previous comment: <?php echo comment_reply_link(array( "before" => " <span ...
1
vote
1answer
262 views

Simple custom theme option not being saved

I'm not a web developer and have been following a tutorial on how to add options to a simple self-written theme. In functions.php I've added the following code: <?php $themename = "Theme Name"; ...
3
votes
3answers
1k views

Reversing the order of posts AFTER the query is performed

I'm am displaying the last 5 posts of a custom post type 'show'. This gives me the latest post first. <?php $args = array( 'post_type' => 'show', 'posts_per_page' => 5, 'order' ...
0
votes
1answer
275 views

How to Convert Custom Fields from Text to Array?

I want to convert my old post data containing custom fields that are stored in a text format like : name , url $ name, url $ name, url etc. I want convert that data and store the new data as an ...
1
vote
1answer
370 views

PHP get the first post separately from array returned by wpdb->get_results()

Apologies if the title isn't clear, can't quite think how to word this. I'm getting a pretty standard list of posts like this: $pageposts=$wpdb->get_results(" SELECT * FROM ...
0
votes
1answer
506 views

Create an Array of Specific Custom Post Meta

I'm having an issue thinking today and ran into a brick wall. What I'm trying to do it take 3 different custom field data for posts and combine them into an array that I can then json encode for use ...
2
votes
1answer
314 views

How do I update a specific object in an array, in user meta?

I have this array, below, to set custom user meta (lh_userbadges) in user_meta but I'm not exactly sure how to update just parts of the array later on... $lh_user_badges = array( ...
3
votes
1answer
675 views

Settings API - save an array of options as one setting (array_push?)

1. Basic settings API callback. Using Settings API my $sanitize_callback validating function looks like: (...) if($type == "foo") { $valid_input[$id] = $option[$id]; } else ...
1
vote
1answer
443 views

Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)

I've been staring at this for hours, and it's clear I'm missing something, but I don't know what it can be... I have custom meta box for adding downloads to a particular post or page. All the data ...
1
vote
1answer
161 views

Echoing a variable inside a function

In the interest of automation, instead of making a long list of code like this <td valign="top"width="50%"><p><label for="Facebook"><strong>Facebook ...
0
votes
1answer
492 views

Custom field outside the loop and inside an array

I am trying to use a custom field inside a widget so it's therefore outside the loop. Taking it a step further, the theme I have is using an array to generate listings which makes it hard for me to ...
4
votes
2answers
5k views

How to get permalink and title from post ID?

I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if ...
0
votes
2answers
516 views

Wordpress loop: Display <div> if posts exist

In a single post template I am trying to output some header text in a <div> and display links to related posts in a <ul> if related posts exist (based on tags). If there are no posts, ...
0
votes
2answers
529 views

Output from Meta Box Array

I have created a meta box and it's storing the post data successfully but I am having trouble outputting the content and displaying it in a sensible fashion - beyond my limited knowledge of PHP. I am ...
0
votes
1answer
760 views

How to save Wordpress Options as an array?

How do I save options as an array using forms? I don't want to use Settings API. Here's working form that saves 3 options separately: <form method="post" enctype="multipart/form-data" ...
1
vote
1answer
265 views

Arrays not working on a WP-Ecommerce product page

I am using WP-ecommerce to build a shop, and have a random product generator on the left and right sidebar. So the same product doesnt appear twice on the page, I have got the post id's from each ...
6
votes
6answers
3k 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 ...
-1
votes
1answer
556 views

Combine two foreach Arrays into one table row

right now I have two foreach arrays - one outputs the artist, the other a track title I would like to combine both so there is a row for each artist and corresponding track for example: Row 1 - ...
0
votes
1answer
747 views

Time & Date on Post - Time Ago Custom Function

I'm using the following custom function to display the timestamp for a post as posted "X minutes ago" or "X days ago" for 14 days and then this changes to the actual date (e.g. 17th December 2010): ...
0
votes
1answer
84 views

post custom values

I have this code: <?php $site= get_post_custom_values('projLink'); if($site[0] != ""){ ?> <p><a ...
1
vote
1answer
274 views

How to check an array of $curauth fields?

How do I check an array of $curauth user data? I need to check to see if one or more $curauth fields have data, and if so, print some html. This throws an array error: <?php if ( !empty( array ...
0
votes
1answer
123 views

Inefficient Query Confusion

Edit #3 - meta_keys as an array This seems to compare more than just the "opening_time" I can set the opening time for the wrong date or even leave it blank and it will still grab a post if the ...
0
votes
2answers
605 views

Echo 2 values from one key in Array with get_post_custom

Edit 12/15/2011 Added Radio Button print code // Add meta boxes to admin panel only needs to be added once add_action('admin_menu', 'plib_add_box'); //Add meta boxes to post types ...
0
votes
2answers
636 views

Echo custom field value in shortcode function

I must be doing something wrong here. I want to display the custom fields "pw_featured_note" & "pw_featured_price" Here is my code so far function featured() { ...
5
votes
2answers
329 views

Why does get_users suddenly return duplicates?

I'm having a hard time figuring this one out. I'm running a simple users query : $args = array( 'role' => 'custom_role', 'orderby' => 'ID', 'order' => 'DESC', 'number' => ...
0
votes
2answers
558 views

Get custom post fields from multiple metaboxes

I'm registering multiple metaboxes in my write posts panels. In functions.php: $meta_boxes[] = array( 'id' => 'products', 'title' => 'Products', 'pages' => array('post', 'page', ...
1
vote
1answer
550 views

How to store multiple values in 1 meta_key with radio input?

How do I store multiple values in one meta_key through a radio input and then display the two values on the page? One value would be a text string and the other would be a link that would go with ...
1
vote
2answers
2k views

Get list of all registered post types slugs

I'd like to get a list (array) of all the post types I registered. Precisely I would like to retrieve their slugs. Could someone help me? thanks!
0
votes
2answers
76 views

Obtaining values from objects

This code works fine and returns two StdClass Objects for each of my two posts: $children = get_pages($args); foreach ($children as $cake=>$element) { $args = array( ...
0
votes
1answer
227 views

Accessing value from associative array

Here's my code: $args = array( 'child_of' => $CurrentPage ); $children = get_pages( $args ); foreach ($children as $child) { foreach ...
0
votes
1answer
207 views

Accessing array elements (get_pages)

I'm trying to access the page ID of the child so that I can recursively call the get_children function on that child (to get grandchildren). if ($CurrentPage) { $args = array( ...
0
votes
1answer
618 views

Add 2 values to post__not_in

How can I add to values to the post__not_in function? For example, I want to exclude $value1 and $value2 from a loop Any ideas? Thanks in advance
0
votes
1answer
405 views

Use premade array as categories in wp_query?

I have a theme options panel that the user can set which categories they want to use which is then saved as an array $blog_cat[0] etc. They can select as many categories as they want for the array ...
0
votes
1answer
656 views

How to include post count in this “get_tags” snippet

Can anyone tell me how I can show a post count in this code snippet? <?php $tags = get_tags(); if ($tags) { foreach ($tags as $tag) { echo '<li><a href="' . get_tag_link( ...
1
vote
2answers
3k views

Working with query_posts ( arrays and query strings)

I'm trying to use the search query along with an array of arguments to narrow down search results, but I'm failing horribly. This is what I have so far. $paged = (get_query_var('paged')) ? ...
0
votes
1answer
123 views

Array: What is this value based on?

I need to do an import of an array of checkboxes, but there is a value that I don't how it is determined. The array is based on a user meta option that I created that shows a list of category ...