Support » Developing with WordPress » How to Return in WordPress Function php file?

  • Resolved Chris

    (@dobeweb)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @dobeweb!

    Great question!

    Have you tried just wrapping it around?

    $html .=  '<div class="post">';
    $html .=  get_post_field('post_content', $post_id);
    $html .=  '</div>';

    Warm regards!

    Thread Starter Chris

    (@dobeweb)

    God! That’s it, thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Return in WordPress Function php file?’ is closed to new replies.