The Loop -> variable? (NOT $post)
-
Hi all. I’ve been hunting and so far come up mostly empty. What I would like to do is send the entirety of the output of The Loop into a variable so I can handle display myself.
I found and started using the $post variable, but while the Wiki claims that all Loop information is accessible from $post, that is untrue. I can make the extra call for get_post_meta, which is not ideal but is certainly doable. Where I’m getting hung up is with the_content. I would much prefer to use the_content() to fetch home page excerpts, since it is already there, but the_content has NO parameter to take display=FALSE. Furthermore (I think because of the way the functions are structured) output buffering via php fails to prevent the output itself (I get the output in the buffer, but it outputs to the page as well.)
Does anyone know of a way to get the result of the_content into a variable? Or another way to do this?
$post would work fine, except for the missing excerpt functionality (perhaps because I am using post_teaser? if so, dang, because I prefer post_teaser.) The reverse would also be fine – assigning the function results inside the Loop to individual variables – but only some of the functions use the display parameter, somewhat inexplicably (not sure why only some of the functions allow display=FALSE; I would have expected either all content-producing functions to do so or none.)
Any help is much appreciated.
- The topic ‘The Loop -> variable? (NOT $post)’ is closed to new replies.