Все работает, за исключением помещения данных в массив в foreach ($posts как $post).
Полный метод:
Код: Выделить всё
$array = array();
$category_name = "locations";
$args = array(
'numberposts' => -1,
'category_name' => $category_name
);
$posts = get_posts($args);
foreach ($posts as $post){
array_push( $array, array(
"title" => the_title($post->ID),
"cnt" => the_content($post->ID),
"id" => the_ID($post->ID),
"link" => the_permalink($post->ID)
));
}
Код: Выделить всё
Post 39http://localhost:8080/testing/post-3/Post 27http://localhost:8080/testing/post-2/Post 15http://localhost:8080/testing/post-1/Array
(
[0] => Array
(
[title] =>
[cnt] =>
[id] =>
[link] =>
)
[1] => Array
(
[title] =>
[cnt] =>
[id] =>
[link] =>
)
[2] => Array
(
[title] =>
[cnt] =>
[id] =>
[link] =>
)
)
Будем признательны за любые предложения.
Подробнее здесь: https://stackoverflow.com/questions/123 ... into-array
Мобильная версия