I'm trying to build an array within "The Loop" of values provided from various functions like the_title()
, the_excerpt()
, the_permalink()
and others. I'd like to do something similar to what follows. The unfortunate thing is that most of these functions immediately print their results rather than returning them. Furthermore, I have checked the available parameters for these, and haven't found any option to force a return.
if (have_posts()) {
while (have_posts()) {
the_post();
$items[] = array(
"id" => get_the_id(), "the_title" => the_title(),
"the_excerpt" => the_excerpt(), "the_permalink" => the_permalink()
);
}
}