Friday, 15 February 2013

php - Create ordered array from post id and custom values from post -


I have a WordPress query, which goes through the post with a custom post type. I have

  $ args = array ('post_type' = & gt; 'custom_post_type', 'posts_per_page' =>; '-1',); $ Post = new WP_Query ($ Args); If ($ post- & gt; is_paus ()) {while ($ post-> is_pos ()) {$ post- & gt; The_post (); $ Id = get_the_ID (); $ Custom = get_post_custom ($ ID); $ Date = $ custom ["custom_date"] [0]; }}  

I need to create an array that will present the ID as keys and dates for the same values:

  Array ([123] ] = & Gt; 2014-1-1 [456] => 2015-2-1 [78 9] => 2013-2-8 [012] => 2011-12-12)  

I completely suck on php arrays I just tried to create an empty array and then specify it values, but nothing happened (just got out of the array).

"post-text" itemprop = "text">

found solution:

  $ date_array [$ id] = $ Date;  

Very easy, now it looks dumb now


No comments:

Post a Comment