最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to Return <div> in WordPress Function php file?

programmeradmin1浏览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!

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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; 
}
发布评论

评论列表(0)

  1. 暂无评论