Support » Themes and Templates » Different style (CSS) on different page

  • Hi

    I am using twentyfourteen (-child) theme. In the header.php file body tag starts with
    <body <?php body_class(); ?>>

    I also have a template page page-mobile.php (which is a copy of page.php with different content.

    I have two css files in a different theme folder I would like to use for the page-mobile.php (page ID 1305) only.

    If I insert my css files in header.php file, it works but it also stuffs up my home page and the rest.

    How can I overcome this problem?

    Following is the folder structure.
    /twentyfourteen-child/style.css (customised for child)

    Many thanks for your ideas in advance

Viewing 1 replies (of 1 total)
  • Hello!

    Because of the body_class() in your body tag, the specific page you are trying to modify should have it’s ID number in some form as a body class. This allows you to create CSS code to target only that specific page, and that is the most commonly used method to do this kind of styling changes, I do it also this way.

    If you use this method, there is no need for any separate css files, you could simply paste that code to your child theme’s style.css file. Could I ask, why you put these css files to other theme directories? I have never tried it, but it is possible that for security reasons WordPress prevents linking stylesheets from other theme’s folders.

    Let me know what happened.

    [signature removed per forum etiquette]

Viewing 1 replies (of 1 total)
  • The topic ‘Different style (CSS) on different page’ is closed to new replies.