0

I need to know what API a plugin would need to use to add text or HTML to the beginning or end of a posts's text when the post is displayed. I have searched on Google - but none of the leads I find have any relevance to the question I ask.

I need to know the API a plugin would need to use if it is to assure that the text of a post or page when displayed will have something beyond what is in the post's database contents.

4

1 Answer 1

1

Add this filter to functions.php file. Make your changes as needed.

function display_my_content( $content ) {
    if ( is_single() ) {
        $the_content = 'Before your content';
        $the_content .= $content;
        $the_content .= 'After your content';
        return $the_content;
    } else {
        return $content;
    }
}
add_filter( 'the_content', 'display_my_content' );

WordPress theme API or plugin API can be used anywhere, so when you develop a plugin you can use the plugin API. All APIs can be found at this link.

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.