Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:59:53+00:00 2026-05-28T02:59:53+00:00

What i am trying to do is call different CSS (for background and other

  • 0

What i am trying to do is call different CSS (for background and other elements) based on the category the post is. It should be very easy, and worked for the pages, but for some reasons it doesn’t want to work for categories.

Here is the code I have:

 <?php
    if( is_page('Turismo a Bra') || is_page_template( 'turismo.php' ) || is_category('Turismo a Bra')  ) 
    {
    ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/turismo-a-bra.css" type="text/css" media="screen" />      
    <?php } elseif ( is_category ('Eventi') || is_page_template( 'eventi.php' ) || is_page_template( 'eventi.php' ) || is_category('Eventi') )
    {
    ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/eventi.css" type="text/css" media="screen" />
    <?php } elseif ( is_category ('Arte e Cultura') || is_page('Arte e Cultura') || is_page_template( 'arte.php' ) || is_category('Arte e Cultura'))
    {
    ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/arte-e-cultura.css" type="text/css" media="screen" />
    <?php } elseif ( is_category ('Enogastronomia')|| is_page('Enogastronomia') ||  is_page_template( 'enogastronomia.php' )  || is_category('Enogastronomia'))
    {
    ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/enogastronomia.css" type="text/css" media="screen" />
    <?php } elseif ( is_category ('Natura')|| is_page('Natura') || is_page_template( 'natura.php' )  || is_category('Natura'))
    {
    ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/natura.css" type="text/css" media="screen" />
    <?php } else {  ?>

    <?php } ?>

As I said, worked perfectly for the page template and the actual page, but not for the categories. I m sur it is very easy, can anybody help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:59:53+00:00Added an answer on May 28, 2026 at 2:59 am

    I believe you are using the wrong method to check category:

    According to the wordpress documentation you use is_category() for archive pages (WP Function Reference/is category)

    To check current posts you use in_category() (WP Function Reference/in category)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call Dispatcher.PushFrame() from several different thread but encounter an error: Must
I'm trying to filter button events based on whether they have a CSS class
I'm trying to call a different tooltip according to an anchor tag's id attribute.
I have piece of function which I am trying to call at two different
In IronPython I am trying to call a PythonFunction with different numbers of arguments
I am using codeigniter and I am trying to call 3 different tables and
I am trying to use str2func to call different methods of my class depending
I'm trying to call a Modal Popup, but the TargetControl is in a different
Good Morning All, I have created a different background and a few other images
I'm trying to call an ASP.NET .asmx webservice, from javascript, using other than the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.