My plugin’s filters and actions don’t run everywhere

I’m developing a WordPress plugin, and I want to do actions on every single page. However, it seems like my plugin will only work if I visiting a page that is using a part of it, for example, a shortcode. On every other pages, it doesn’t do anything. How can I tell WordPress to run my plugin’s hooks even if it’s not used on that specific page?

I tested it with this code. If I open a page that is using a shortcode registered by my plugin, “HUH?” will appear on the very top of the page.On every other pages, there’s nothing…

add_action('init', 'myplugin_init');
function myplugin_init() {
    echo 'HUH?';
}

Read more here: My plugin’s filters and actions don’t run everywhere

Leave a Reply

Your email address will not be published. Required fields are marked *