phpwordpress

what's the difference between get_posts and the_content?


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


Solution

  • 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.