• Resolved Doodlebee

    (@doodlebee)


    I had a quick question:

    I’m trying to use WordPress as a CMS. A blog is integrated as part of the site, but it’s not the *main* part of the site. So I’m relegating all “blog” stuff to a single category, which will list categories beneath that main “blog” category.

    Now, under this main category, I would like *any* posts that fall under it to have the same template. So I’ve used:

    <?php if (is_category('blog-posts') || in_category('blog_posts') { ?>

    it works *okay*… it’s kind of halfway there. But if you go to a post in a subcategory of “blog-posts”, the layout changes back to the default – which I don’t want. I want the “blog-posts” category – and all the subcategories – to have the same layout. Now, I *thought* that the “in_category” would take care of that (seeing as how the posts will be marked with 2 categories: “blog-posts” *and* whatever subcategory it’s in) – but it doesn’t. I know why, too, and I totally understand why it works that way – just something I didn’t think of, I guess.

    Now, the possibilities of adding in subcategories are endless, so I’d like to do something a teensy bit more “automated” than adding in another is_category('whatever') every single time a new one is created. I’d just like it if, when a subcategory to “blog-posts” is added, it immediately takes on the layout for the parent category. (I’ve also already thought of making my category the default and doing conditional for the rest, but we’re back to the same problem, because many static page categories can also be added – so either way, I’m screwed.)

    What am I missing? A poke in the eye with the right answer (or direction *to* the right answer) would be great. I’m starting to think I’ll need to custom-write something though – so if there’s already an existing…well *anything* for this, that’s be great too. In the meantime, I’ll keep looking.

    Thanks for any help anyone can offer 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Doodlebee

    (@doodlebee)

    Okay – found (part of, anyway) the answer. There’s a thread here and a plugin here.

    However, neither solution seems to be functioning. I will push on, though…

    MichaelH

    (@michaelh)

    Couldn’t you test to see if the category parent is blog-posts? Course if you had a sub-sub-category of blog-posts that would nix that…

    Thread Starter Doodlebee

    (@doodlebee)

    yeah – I did it though 🙂

    The thread I mentioned up there had

    add_action('template_redirect', 'audette_inherit_template', 1); placed at the *beginning* of the code. I stuck it at the end, and it works like a charm. Yay!

    Hope it helps someone else 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Category template question’ is closed to new replies.