• My child themes functions.php file enqueues the parent theme style.css after which it enqueues page specific styles.

    My parent theme functions.php then enqueues the child theme style.css as it is supposed to do.

    Unfortunately the child theme css overwrites the page specific syles

    How do I, a 75 year old, so be gentle in your replies, solve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    The child theme style.css should be enqueued in the child theme as well – if you do it in the parent theme you would lose the changes after a theme update, and preventing that is the purpose of child themes.

    Try making the page styles more specific, to override the default CSS. Here is an article about CSS specificity: https://www.smashingmagazine.com/2007/07/css-specificity-things-you-should-know/

    Hope that helps.

    Thread Starter auldbert

    (@auldbert)

    Hello,

    First of all thank you for your response. Perhaps in my initial and first “how to” post I should have given more detail.

    I am using the twentyfourteen theme and my understanding is that the following line in its functions.php file will always load the active theme stylesheet be it parent or child
    wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() );

    So my situation is one in which my child functions.php loads its parent style and then page specific styles after which the parent functions.php loads the child style and I had thought that a solution might lie in somehow changing the order of stylesheet loadings.

    I resorted to using !important in the page specific css that I did not want overridden.I knew nothing of css specificity so I thank you for that reference as it will certainly help prioritise styling.

    However I still think there must be a way to better enqueue the stylesheets so for a time I will leave this post as unresolved.

    Regards to all

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘enqueuing child theme page specific styles’ is closed to new replies.