The
sidebar.php
is, as you guessed, the file that will display all of the information we want in the sidebar. Since we have already included the file in our index.php
, all we have to do is put the code in this file and our sidebar will show up on the homepage.
1
2
3
4
5
| <div class = "sidebar" > <?php if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar() ) : else : ?> <?php endif ; ?> </div> |
Yup, that will be all of the code that's added to our
sidebar.php
to make it functional. We call the div
that we created in our style.css
, and the code below will make it so that we can add widgets to our sidebar in the order and way we want them via the WordPress backend. However, like many features, we have to modify ourfunctions.php
file first to make this feature work properly.
1
2
3
| //Some simple code for our widget-enabled sidebar if ( function_exists( 'register_sidebar' ) ) register_sidebar(); |
The code just tells WordPress to register a sidebar which we called in our
sidebar.php
.
No comments:
Post a Comment