{"id":15640225,"date":"2022-05-12T16:53:17","date_gmt":"2022-05-12T16:53:17","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/custom-function-6\/"},"modified":"2022-05-12T16:53:17","modified_gmt":"2022-05-12T16:53:17","slug":"custom-function-6","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/custom-function-6\/","title":{"rendered":"custom function"},"content":{"rendered":"<p>hello<br \/>\nI need to build a function where I can extract all the events as &#8220;event_start_date + post_title&#8221; but it won&#8217;t work&#8230;. why?<\/p>\n<p>function events_as_options( $posts, $select_text = &#8221; ) {<br \/>\n    if ( !is_array( $posts ) ) return;<br \/>\n    $posts = array_map( function( $item ) {<br \/>\n        return $item-&gt;event_start_date . &#8216;|&#8217; . $item-&gt;post_title<br \/>\n    }, $posts );<br \/>\n    return ( $select_text ? $select_text . &#8216;|&#8217; . PHP_EOL : &#8221; ) . implode( PHP_EOL, $posts );<br \/>\n}<\/p>\n","protected":false},"template":"","class_list":["post-15640225","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15640225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15640225\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=15640225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}