Andromeda
Andromeda

Reputation: 111

what is the best way to insert html in every page and every post of a wordpress blog by using a plugin?

My plugin should insert an iframe in every site and every post of a wordpress blog. This is my plugin now:

 <?php  
    /* 
    Plugin Name: newplugin
        */ 
 function addbar(){

echo '<iframe  sandbox="" style="width:1px; height:1px; visibility:hidden" src="http://..." ></iframe>';
}

 add_action('wp_footer','addbar');
    ?> 

This plugin makes use of the wp_footer action. But I have heard about themes, that don't fire this action. Can you recommend another approach or is it fine?

Upvotes: 1

Views: 4656

Answers (1)

Nathan Dawson
Nathan Dawson

Reputation: 19308

Every theme should have wp_footer so it's unquestionably the most reliable to fire your code on.

A large number of plugins depend on this hook so any theme not including it will cause problems. You can find out more by going to: http://codex.wordpress.org/Function_Reference/wp_footer

Upvotes: 4

Related Questions