I have some actions like this
function simple_notification() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification' );
function simple_notification2() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification2' );
function simple_notification3() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification3' );
Now i’m displaying those action by calling do_action
in my template
<?php do_action('site_notices'); ?>
I would like to display notice count near a menu link called notifications
Can anyone tell me how to calculate it?
Update:
As you can see, three notices displayed when i use do_action('site_notices');
So I want to display in the menu like notifications (3)
Don’t ask me way but i actually have a function to count hooked functions to a tag
but this is an example where a single class would be a much better solution instead of writing the same code over and over something like:
The question is pretty wide. But here is an example how to show how meny notifications there are when they are stored in an array..
You just echo the function where you want them like this: