Insert plugin content before body end

How do I make plugin’s content appear in a place I want? For example let’s say I have a plugin that output’s a paragraph:

echo "<p>foo<p>"

If I do this it will appear on a page outside the DOM. How to make it append for example just before the end of body using PHP?

1 Answer
1

Hook the wp_footer action to output markup before </body>:

function your_function() {
    echo '<p>foo</p>';
}
add_action('wp_footer', 'your_function');

Leave a Comment