Created
May 28, 2015 23:22
-
-
Save dannyb195/2c74017c52ef7d625c35 to your computer and use it in GitHub Desktop.
Inserting content after WP in-content paragraph (not really tested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$content = get_post( 1558 ); | |
$content = $content->post_content; | |
$content_array = explode( "\n", $content ); | |
echo 'before<pre>'; | |
print_r($content_array); | |
echo '</pre>'; | |
foreach ( $content_array as $k => $v ) { | |
echo $k . ' ' . strlen( $v ) . ' </br></br>'; | |
if ( 1 == strlen( $v ) || '<!--more-->' == $v ) { | |
unset( $content_array[ $k ] ); | |
} | |
} | |
$content_array = array_values( $content_array ); | |
array_splice( $content_array, 3, 0, '<div>sdf</div>' ); | |
echo 'after<pre>'; | |
print_r($content_array); | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment