[WordPress] Properly Filtering Post Content (And Understanding apply_filters)
<?php | |
$post->post_content = $my_content; |
<?php | |
$post->post_content = apply_filters( 'the_content', $my_content ); |
<?php | |
/** | |
* Assume $contents is an array of information we want to convert into content for a post. | |
*/ | |
$new_content = ''; | |
foreach ( $contents as $line ) { | |
if ( false === strpos( $line, $name ) ) { | |
$new_content .= $line; | |
} | |
} | |
$post->post_content = $new_content; |
<?php | |
/** | |
* Assume $contents is an array of information we want to convert into content for a post. | |
*/ | |
$new_content = ''; | |
foreach ( $contents as $line ) { | |
if ( false === strpos( $line, $name ) ) { | |
$new_content .= $line; | |
} | |
} | |
$post->post_content = apply_filters( 'the_content', $new_content ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment