Learn to hide sidebar on home page of WordPress Website.
There are times when you like to hide sidebar on WordPress home page only, in some of the themes there are options where you can choose different sidebars for home page and posts. but if you like to hide sidebars on WordPress home page only and not from the posts then this can be a little problem.
In the layout of most of the themes you have the option of removing the sidebar but with this it will also remove the sidebar from the post.
If you want to hide the sidebar on WordPress home page while keeping it displaying on the posts, you have tow options to make this happen.
- By creating a Custom Page
- By making a change in code.
1. In this way you have to make two pages fist is the one which you want to make your home page in this you have to create the page you like with the sidebar disabled. Many websites use this method, as you can design the homepage the way you like.
After this you have to create a page where all the posts of your blog will be displayed in the order they are published.
Now you have to go to the dashboard»settings»reading here you should select the option A static page. Now you have to select the page with no sidebar as your homepage and the page you created to display your recent posts as posts page.
That’s it, you are done. Now you have a WordPress home page with no sidebar.
2. In this tutorial we will focus on the method where you have to make change in code.
First you have to go to go to the index.php file, find the below code in it.
php get_sidebar(); ?>
Now you have to replace the above code with the one below.
<?php if (!is_front_page())
This code will help you to hide sidebar on the home page of your WordPress website.