• Resolved RSimpson

    (@rsimpson)


    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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Remove them from page.php if you have one defined in that particular theme.

    Thread Starter RSimpson

    (@rsimpson)

    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

    Thread Starter RSimpson

    (@rsimpson)

    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).

    Thread Starter RSimpson

    (@rsimpson)

    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.)

    Thread Starter RSimpson

    (@rsimpson)

    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! ??

    Cheers,
    Robert

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘display cats and archive on blog only’ is closed to new replies.