Control your WordPress sidebar

Source: Internet
Author: User

Plug-ins for managing the sidebar include widget logic and sidebar modules (SBM)
(Silly B Mei ~), This article describes how to manually writeCodeTo replace these cumbersome but dazzling plug-ins.

Of course, the "gadgets" option in WordPress 2.7 can also control widgets.
However, after repeated experiments, we found that the style could not be unified and the controllability was low. I personally think it is a relatively chicken feature. I will not talk about it here.

Go to the topic. The Sidebar plug-in displays different content on different pages. We use the WordPress function to determine the current page.

Edit the sidebar. php file in the template. We can add:

<? PHP if (is_home () {?>Your Content<? PHP }?>

In this way, only a widget is displayed on the home page.

We rely on the is_home () function to determine, of course, there are many:

Is_front_page () Homepage
Is_admin () Administrator Account
Is_single ()ArticlePage
Is_page ()
Page
Is_category () Document category page
Is_tag () Article Tab
Is_archive () archive page
Is_404 ()
Page cannot be found
Is_search () search result page
Is_feed () Subscription page

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.