Code WordPress Work

Processing Custom Post Type Content in WordPress

I’m using WordPress custom post types in a project right now, which requires a number of new content sections that are similar to the_post(). In the WP back end, the new content panels are created using add_meta_box() with the TinyMCE WYSIWYG editor so that HTML can easily be added to the content. However, since I have to retrieve the meta box content using get_post_meta(), none of the usual content filters are applied, so we just get the text and any hand-entered HTML, but no automatic paragraph and line break tags or shortcodes. In this case, we need to run the following code on those pieces of content:

echo apply_filters('the_content',$content);

Often when I post code related bits here, it’s for future reference for myself. I know I’m going to need this again, so I know to look for it here.

Leave a Reply

Your email address will not be published. Required fields are marked *