• If someone could help me out here I’d really appreciate it. I’m at the last hurdle of making my site work.

    I want to call a specific sidebar.php file on the attachment page of images from posts from specific categories. If that makes sense.

    In other words, I want francesidebar.php to load when someone clicks on an image within a post which is in the france category.

    I assumed this would work but it doesn’t.

    <?php if (is_attachment ('category=10') ){ ?>
    <?php include('francesidebar.php'); ?>
    <?php } ?>

    thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have you tried

    <?php if (is_attachment ('category=10') ) {
    include (TEMPLATEPATH . '/francesidebar.php');
    } ?>
    Thread Starter bazzle83

    (@bazzle83)

    Yes I’ve tried that, it doesn’t look at the category ID between the brackets, it only looks at the is_attachment and checks if the page is an attachment.

    I’ve also tried in_category.

    <?php
     if ( in_category('3') ) {
     include(TEMPLATEPATH . '/francesidebar.php');
     }
     ?>

    For some reason this works fine on a single blog post on single.php, but not on image.php or attachment.php.

    Ok, I think I understand more of what you’re looking for after reading your original post again – it’s the category of the parent post. Sorry I can’t try to help any further, I wasn’t sure how to do this either when I tried to do something with the parent category of an image within a [gallery].

    Thread Starter bazzle83

    (@bazzle83)

    Thanks anyway mojorob, I’ve redesigned my site to accomodate not being able to do this.

    Another things which is frustrating me is the single cat title tag, which only displays on a category page. I want it to display on a single post page aswell, but it doesn’t.

    I don’t understand why certain tags can only work on certain pages, or am I missing something here?…

    Try this on single.php:

    <?php if ( in_category(1) ) { ?>
    <h2>YOURCATEGORY1</h2>
    <?php } elseif ( in_category(2) ) { ?>
    <h2>YOURCATEGORY2</h2>
    <?php } elseif ( in_category(3) ) { ?>
    <h2>YOURCATEGORY3</h2>
    .
    .
    .
    <?php } else { ?>
    
    <?php } ?>

    `
    <?php
    if ( in_category(‘3’) ) {
    include(TEMPLATEPATH . ‘/francesidebar.php’);
    }
    ?>
    `
    For some reason this works fine on a single blog post on single.php, but not on image.php or attachment.php.

    Just delete <?php get_sidebar(); ?> in your image.php and replace it with <?php include(TEMPLATEPATH . '/francesidebar.php'); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘question about the conditional tag: if (is_attachment)’ is closed to new replies.