0

I make plugin for WordPress, and I want to add content php file to end of post content.

This is my plugin file:

add_filter('the_content', 'modlifyContent');

function modlifyContent($content)
{
    global $post;
    $content .= include(plugin_dir_path(__FILE__) . 'my_plugin_test.php');
    return  $content ;

}

but, content php file is added at start of post content.

This is content php file which I want to include to of post content:

<div>
<a href="<?php echo get_post_meta($post->ID, 'url', true); ?>">Enter</a>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed ipsum augue.</span>
</div>

How I can include content of php file to the end of post content?

1 Answer 1

1
add_filter('the_content', 'modlifyContent');

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

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.