I present to you my example of adding a sidebar.
In functions.php :
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Футер на странице записи', 'before_widget' => '', 'after_widget' => '', 'before_title' => '<div class="title">', 'after_title' => '</div>', ));
I needed to add a widget at the bottom of each page.
Code in footer.php :
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Футер на странице записи")) : ?>
My widget was supposed to be shown everywhere except for the home page and the single entry page, so the full code looks like this:
<?php //Проверяем, что страница не является главной или является отдельной страницей ?> <?php if (is_front_page() === false OR is_single() === true): ?> <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Футер на странице записи")) : ?> <?php endif; ?> <?php endif; ?>
To style your footer or widget separately for each page, you need to specify the styles. Wordpress adds unique classes to the body tag for each category of post, page, or post. It looks like this:

Let us consider examples. css for styling the custom-widget on ALL pages of individual entries:
.single-post .custom-widget { background: darkorange; }
only for the category with id=191 and only if the user has logged in:
.category-191 .logged-in .custom-widget { background: #faa; }
By analogy with these examples, you can write for almost any page. Hope this helps you. Good luck.