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

As Sally highlights, you can use in_array() like this (untested): // target ids $ids = array(123, 321, 213); if (!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $ids)) { // do jazz } else { // do stuff }

Printing out JSON array returned [closed]

Setting the proper dataType for the request is an important detail not considered in the answer above (this causes jQuery to send a HTTP Accept header with the request – and it will be expecting JSON data in the success callback as well): dataType: ‘json’, success:function(json){ var content=””; jQuery.each(json, function(i, v){ content += ‘<li>’ + … Read more

Accessing array elements (get_pages)

The return set of $children is an associative array. So you can get the IDs with: $children = get_children( $args ); foreach ($children as $k => $v) { echo $k; // do stuff with $v }

Accessing value from associative array

You’re doing one to many loops. What you want to be doing is this: $args = array( ‘child_of’ => $CurrentPage ); $children = get_pages( $args ); foreach ($children as $key => $value) { echo $key[‘post_title’]; }; Or you could also: $args = array( ‘child_of’ => $CurrentPage ); $children = get_pages( $args ); foreach ($children as … Read more

post custom values

Use var_dump($site[0]) to see the structure of the array. And once you know that, then you can properly reference an item in that array. (You could also do var_dump($site) to get a full picture of what’s going on.)

Get custom_user meta value and add entry

You need to pass get_user_meta a third parameter to prevent it from returning an array. That is where the mistake is, not with the add/update functions. $invoice_meta = get_user_meta( $_GET[‘id’], ‘invoices’, true); You will need to clean up any data already in the database or the existing nested arrays will still cause trouble.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)