The code is:
function my_custom_function( $html, $content ) {
$html .= get_post_field('post_content', $post_id);
return $html;
}
$priority = 10;
add_filter( 'tps_the_content_after', 'my_custom_function', $priority, 2 );
If my content is "this is my content
", then the code return "this is my content
"
I want to add <div>
before the content, but I don't know how to write the code,
it should return like this
"<div class="post">this is my content</div>"
Thank you!
The code is:
function my_custom_function( $html, $content ) {
$html .= get_post_field('post_content', $post_id);
return $html;
}
$priority = 10;
add_filter( 'tps_the_content_after', 'my_custom_function', $priority, 2 );
If my content is "this is my content
", then the code return "this is my content
"
I want to add <div>
before the content, but I don't know how to write the code,
it should return like this
"<div class="post">this is my content</div>"
Thank you!
Share Improve this question asked May 10, 2020 at 10:34 Chris CreedChris Creed 92 bronze badges1 Answer
Reset to default 3Your function should look something like this
function my_custom_function( $html, $content ) {
$html .= get_post_field('post_content', $post_id);
$html = "<div class='post'>" . $html . "</div>";
return $html;
}