Salvatore
Member
Posted 4 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.
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.
Salvatore
Member
Posted 4 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');
}
?>
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?
Salvatore
Member
Posted 4 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.
Could you test if you can get *anything* (normal text) printed on the page with the code snippet?
Salvatore
Member
Posted 4 years ago #
Done, and nothing is happened...