tags:

views:

109

answers:

3

What's the difference ? How to replace the_content (used within a loop) with get_posts ?

+1  A: 

get_posts() does what the name says: collecting a bunch of posts. the_content() returns the content of a single post. They are not interchangeable.

toscho
Well I mean the_content within a loop
Of course, `the_content()` cannot be used outside of the loop.
toscho
+1  A: 

Template Tags/the content « WordPress Codex, and you're probably interested in Template Tags/the excerpt « WordPress Codex, too.

songdogtech
+1  A: 

Basically the_loop is similar with

foreach  (get_posts('showpost=-1') as $mypost) {
     //and the output of the_content is similar with
     echo $mypost->post_content;
}

PS : when you don't use the_content in a proper LOOP and change it with the above approach, then you will lose several wordpress features such as Shortcode API, Content Sanitation, etc. These feature will help you clean your content and add more feature.

justjoe
Thanks. I didn't know that kind of php syntax "as mypost", will search on it.
it's PHP. It's call foraech...i will try to find the link for you or try search in php.net
justjoe