problem with wordpress plugin repeating action
I'm writing my first Wordpress plugin, and though not the most original one, I still cannot get it to work properly. The problem is that the function which echoes what needs to be echoed in the footer is doing it twice... to be precise, it echoes, then when it reads the add_action in the footer it repeats the action. Here's the code, if anyone knows where I'm missing it please let me know:
function add_copyright(){
$the开发者_StackOverflow社区_array = fof_check_db();
$copyright_message = '<a href="' . $the_array[0] . '">' . $the_array[1] . '</a>';
echo $copyright_message;
}
add_action('wp_footer', 'add_copyright');
Also, I tried changing the echo for return, but that didn't even display anything.
Any help will be welcomed
One explanation - if the theme isn't calling wp_footer() twice, is that your code that calls add_action() is being called twice. That would add the action again and hence the wp_footer() code that calls do_action() would cause add_copyright() to be called twice - since any number of callbacks can be hooked into an action. (That is perhaps the thinking behind @Frederik asking where you call add_action)
精彩评论