WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Tags (7 posts)

  1. Salvatore
    Member
    Posted 9 years ago #

    I just want to say to WP to load a particular header when there is a post filed under a specific category. The conditional tag "is_category()" is not able when the single post is visualized, while I wouldn't use "is_single() " for every single post of that specific category: is there any way to do that?

    Thanks.

  2. Minna
    Member
    Posted 9 years ago #

    I found this on the Codex page for is_category tag:
    <?php $post = $wp_query->post; if ( in_category('1') ) { ?>
    that particular header
    <?php } ?>

    I tried that in my Post template, single.php, (inside the loop, despite the header in Codex) and it worked.

  3. Salvatore
    Member
    Posted 9 years ago #

    Oh, I've submitted this string but nothing has changed: what's wrong?

    <?php
    $post = $wp_query->post;
    if ( in_category('2') ) {
    include(TEMPLATEPATH . '/menu.musica.php');
    }
    ?>

  4. Minna
    Member
    Posted 9 years ago #

    What site are you working on? The one linked from your name? Can you point to an example where it's supposed to be working? Where did you put that bit of code?

    Is the file where include() expects it to be? Does it have adequate permissions?

  5. Salvatore
    Member
    Posted 9 years ago #

    Site is this: http://www.winnicott.it/blog/
    The header works on: http://www.winnicott.it/blog/index.php/category/musica/
    The code is on "inc.myheader.php" in the main directory of the blog.

  6. Minna
    Member
    Posted 9 years ago #

    Could you test if you can get *anything* (normal text) printed on the page with the code snippet?

  7. Salvatore
    Member
    Posted 9 years ago #

    Done, and nothing is happened...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.