Include php file after post content in WordPress

0 Comments

Last updated on

Wants to add content PHP file to the end of post content?

You might look below snipped to do the same.

add_filter('the_content', 'UpdateContent');

function UpdateContent($content)
{
    global $post;
    //output buffer start
    ob_start();
    include(plugin_dir_path(__FILE__) . 'plugin_test_file.php');
    //clean output buffer and returns its content
    $append = ob_get_clean();
    return  $content. $append;

}

Leave a Comment