The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

formatting the post_content outside of loop (2 posts)

  1. Paul Menard
    Posted 10 years ago #

    Greeting all. I just posted this to the wp-hackers groups and figuered that was wrong since this is a support issue. (more like dumb user issue).

    Here is my code:

    $post_email = get_post($email_post_id);

    The functionality is pretty basic. I'm calling get_post with an ID that was determined earlier in the code. This does properly populate the 'post_email' variable. I'm calling 'setup_post' as someone suggested in an article I found in these forums.

    My problem is I'm building an HTML email I need to get access to the formatted post output. Normally on a page I would just call the_content() and the properly formatted body would be displayed. Problem is the the_content() function will echo the formatted output to the screen. I need to redirect this same output instead to a local variable to be echoed to the HTML email content.

    So how is this done? I know someone somewhere has done this before.


  2. Joshua Sigar
    Posted 10 years ago #

    You can call the following function

    And then you may need to apply the filters; just peruse the_content()

Topic Closed

This topic has been closed to new replies.

About this Topic