Available for college WordPress theme (template) modification Tutorial (ix): Create a separate sidebar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.