How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?

I would like to add toggle style button near the left sidebar for collapsing and opening/closing the left sidebar of Wordpress default Twenty Fifteen theme.

I have this code for only removing the left sidebar:

    body:before,
#sidebar,
#colophon,
.entry-footer {
    display:none;
}

.site-content {
    margin: 0 auto;
    float: none;
    width: 100%;
    max-width: 1200px;
}

So how can I also add an arrow for manually opening and closing the left sidebar of twenty fifteen theme? And how to stretch whole site automatically when the left sidebar closed?

Topic theme-twenty-fifteen php css theme-development themes Wordpress

Category Web


As you've done, you removed the sidebar with CSS, however to display on a toggle you'll have to use jQuery. You could do something with toggleClass(); on a click function.

In your css you simply add the class that will toggle and then display the sidebar again.

Stretching the site automatically will rely on CSS again. Let me know if there is anything specifically I can help with.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.