Hi DP members, I only want to see the sidebar in my posts and not in my other pages. Please help me on how to remove the sidebar in wp pages. Thanks in advance.
Delete <?php get_sidebar(); ?> from the theme files index.php, archive.php, search.php and page.php. It only has to be in the file single.php.
you actually only want to remove it from single.php, not index.php.... if you remove <?php get_sidebar()?> from index.php it will remove the sidebar from your main page.
How old is your blog? do you have many post? if you have more then a few post and you remove your side bar you will need no longer have to worry if is there or now. You will conveniently create a 404 master piece. I would buy a nice 404 template for that...
If the <?php get_sidebar(); ?> PHP: is in a common template like footer, removing it will make it disappear from all the pages, post, index.. Use this code to replace the above code. <php if (is_single()) { <?php get_sidebar(); ?> } ?> PHP: It'll show the sidebar on single posts only. To show it on only index and single post, use this code <php if (is_single() || is_home() ) { <?php get_sidebar(); ?> } ?> PHP: