Check if has any sidebar active on current page

I believe the issue here is a problem with vernacular.

is_active_sidebar isn’t page specific — just checks to see if it has data within it throughout the entire site.

You are asking a different question.
Sounds like you are asking “does this template reference and sidebars AND do any of those sidebars have data in them,?” it also sounds like you don’t want to reference the sidebar names at all and you’d like this to be a generic question across the board.

That last bit makes this difficult and can potentially turn this into an architectural problem — not a WordPress problem. Think of WordPress as a waiter — it just takes your orders and gets you results. It wasn’t built for you to ask questions like “is anyone in the restaurant eating steak?” — so it doesn’t have anything for you there.

You COULD tie into https://codex.wordpress.org/Plugin_API/Action_Reference/dynamic_sidebar

Then you could set a variable or call a function anytime someone calls a sidebar that has data in it — this would allow you to react in those moments.

Leave a Comment