Sometimes we want to have a page with a unique widget area that won’t appear on all pages, like widgets in the sidebar do.
Read on to learn how I dynamically create a uniquely-named widget area per page.
I will be using the twentyfifteen page template as an example, but the code will work on any theme as long as you cup/paste the right snippet.
We will start by creating a new page template, let’s call it page_dynamic_widget.php
The relevant part of the code is this one:
Then we need to add this somewhere in the functions.php file
And there you go, as soon as you create a page and assign it the correct template file, you will see a new widget area appear in the appearance > widgets page.