Hi folks,
Does anyone have a quick and dirty way I can alter my sidebar.php so that categories and archives appear only on my blog and not the pages?
Cheers,
Robert
Hi folks,
Does anyone have a quick and dirty way I can alter my sidebar.php so that categories and archives appear only on my blog and not the pages?
Cheers,
Robert
Remove them from page.php if you have one defined in that particular theme.
Hi Rhand,
I can see <?php get_sidebar(); ?> in there, I don't want to remove the sidebar completely, I just want to remove the categories and archive when people are viewing pages instead of the blog, I still want the pages navigation to show up. Is there a quick if else conditional I can throw around the 2 parts in sidebar.php?
Cheers,
Robert
Anybody? :)
You could try something like...
if (!is_page){
}
...in sidebar.php around the categories and archives code.
Yep, you can use the is_page() conditional tag, as long as your sidebar isn't widgetized. Otherwise you'd need to create 2 sidebars (one for your blog and one for the pages).
Hi guys,
I tried the is_page() conditional and the cats and archive disappeared completely. My blog is not the home page, it's the posts page which I set under Settings > Reading.
Cheers,
Robert
Notice that adam-s' code has an exclamation mark (!) in front of the is_page() (which would be like saying isnt_page() if you know what I mean)...
if(!is_page()){
// Your categories and archives
}
That would make the categories and archives appear in the home page, in the single post page, etc. Everywhere but the pages (eg. About, Contact, etc.)
Sorry it took me so long to reply to this, I'd made a mistake in my own code (daft thing) and !is_page() does in fact work :)
Mark as resolved! :D
Cheers,
Robert
You must log in to post.