0

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!

1 Answer 1

3

Your 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; 
}
1
  • $html .= '<div class="post">'; $html .= get_post_field('post_content', $post_id); $html .= '</div>'; May 10, 2020 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.