With a few extra lines in my functions.php I've created a shortcode that lets me include the content of a post:
function include_content( $atts ) {
$id = (int) $atts['id'];
if ( ! $post = get_post( $id ) )
return '';
return apply_filters( 'the_content', $post->post_content );
}
add_shortcode( "include", "include_content" );
Now, if I make a posting like
A few weeks ago I published an epic statement: [include id="345"]
WP generates
<p>A few weeks ago I published an epic statement: <p>FTW!<br />
just my 2 ยข</p>
</p>
So, obviously the content of the old post is wpautop'ed before it's included. If simply returning $post->post_content, that content would end up unrendered (i.e. no <br />) within the outer posting. Now, how can I get rid of the paragraph tags around the imported post, i.e. how can I do the include first and wpautop the whole thing after? Any code improvements are welcome, too!
Thanks!
<blockquote>that and maybe evenstrip_tags()the_contentand insert the tag on a new line which should look and feel better, since you're quoting another post. – soulseekah Oct 18 '11 at 5:42<p>and the last</p>in an imported post, you either strip all the<p>or not strip the<p>; try to turn this into the filtersubstr( $post->post_content, 3, -4 ), which answers your initial call for something to "get rid of the paragraph tags around the imported post", you may end up with mismatching<p>tags in several circumstances, and the whole point of markup goes down the drain and you have<p>inside<p>. – soulseekah Oct 18 '11 at 6:04