Yesterday Lei son to the homepage template creation Method said, presumably everyone looked after know how to create a template, we just need to add template name in the template file created, you can use when the template. We are changing the theme is, if the individual page would like to put some style or JS effect up, but do not want to have other pages, we can use the method of creating a template to solve it. The sidebar is the same, if you just want to put a side bar on a page, we can also create a sidebar for this page, so you can be more flexible to use. There is another way that is the use of plug-ins, this plug-in is called Widget logic, the installation of the activation will be in each gadget inside the widget logic text box, you need to enter a judgment function in it, if you are interested to download down to see, If the novice's words are not recommended to use, the following is the more commonly used methods.
In the functions.php of the default theme we find this code:
Function twentyeleven_widgets_init () {register_sidebar ( array (' Name ' => __ (' homepage sidebar ') ), ' id ' => ' sidebar-home ', ' description ' => __ ( ' Add ' home sidebar content here '), ' Before_widget ' => ' <div id= '%1 $ s " class=" widget %2$s ">", ' After_widget ' => " </div> ", ' before_title ' => ' I can create countless sidebar through the above method, as long as you need to use this method to create. Once created, we will make the call and put it in the template file you need to use. The code is:
<?php if (!dynamic_sidebar ( ' sidebar-home ' ) ) : ?><?php endif; ?><?php if (!dynamic_sidebar (' sidebar-1 ')) : ?><?php endif; ?>//can be called by ID name or by name to call
This way we can see the sidebar we created in the gadget behind the scenes, and try it out if you need it!
Available for college WordPress theme (template) modification Tutorial (ix): Create a separate sidebar