WordPress.org

Ready to get started?Download WordPress

Forums

Different style (CSS) on different page (2 posts)

  1. oavs
    Member
    Posted 4 months ago #

    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.
    themes/
    /mobile/themes/mob/css/custom-1.css
    /mobile/themes/mob/css/custom-2.css
    /twentyfourteen-child/style.css (customised for child)
    /twentyfourteen/style.css

    Many thanks for your ideas in advance

  2. Noone Here
    Member
    Posted 4 months ago #

    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]

Reply

You must log in to post.

About this Topic

Tags