purothemes / polestar

Lead the way with Polestar. It's fast loading, responsive, lightweight and flexible design is perfectly suited for building dynamic pages with SiteOrigin's Page Builder and selling with WooCommerce.
https://purothemes.com/themes/polestar/
GNU General Public License v2.0
10 stars 2 forks source link

Prevent child theme css file loading between unminified and minified parent theme css #1

Closed liam-moore closed 6 years ago

liam-moore commented 6 years ago

I'm using the polestar theme as a parent theme and I'm finding that I can't get a child theme css to display. I discovered that there appears to be an unminified and a minified css loading from the parent theme and when I enqueue the child css, it gets loaded between these two, thus rendering the child theme css irrelevant. It basically goes like:

<link rel='stylesheet' href='../polestar/style.css' />
<link rel='stylesheet' href='../polestar-child/style.css' />
<link rel='stylesheet' href='../polestar/style.min.css' />

I can't figure out to load the child theme css after the parent minified css, or better yet, not load both files.

Could this be a polestar bug, or is there a trick I'm missing?

Misplon commented 6 years ago

Hi Liam

Thanks for reaching out. The unminified parent stylesheet is included in the parent theme folder to meet theme directory guidelines. Only the minified version is enqueued.

If you setup your child theme stylesheet enqueue like this: https://github.com/purothemes/polestar-child/blob/master/functions.php and nothing else, you should land up with only the parent minified stylesheet and the child stylesheet as required.

Misplon commented 6 years ago

Let me know how it goes. We'll definitely solve this :)

liam-moore commented 6 years ago

Hi Andrew,

Thanks for the speedy reply! Just having bother getting the child theme to show up under a selectable theme – it's disappeared now where it was previously always there...

My folder structure:

wp-content > themes > polestar
wp-content > themes > polestar-child

And then the CSS info at the top of the file:

wp-content > themes > polestar-child > style.css
/*
Theme Name: Polestar Child
Description: Child theme edits to the Polestar parent theme.
Template: Polestar
*/

And then the PHP you provided in:

wp-content > themes > polestar-child > functions.php
<?php
/**
 * Enqueue theme scripts and styles.
 */
function polestar_child_scripts() {
    // Child theme stylesheet.
    wp_enqueue_style( 'polestar-child', get_stylesheet_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'polestar_child_scripts', 8 );

Sorry for deviating from the original request/issue, but could the functions.php code be doing something!?

Misplon commented 6 years ago

Try:

template: polestar

Ref.

liam-moore commented 6 years ago

Wow so lowercases template: polestar worked! I changed the 8 to 80 in:

add_action( 'wp_enqueue_scripts', 'polestar_child_scripts', 8 );

And that works, but now the css from my child theme is showing an older version of a file I uploaded. Tried clearing cache/different browser/etc. I can see in code inspector a version attached to the child theme css:

style.css?ver=4.9.2:9

Is there a way to prevent this too, or is this part of the polestar theme?

Thanks for your help on this!

Misplon commented 6 years ago

Glad to hear you've made progress :)

That's core behaviour. If no version number is appended, WP will append its own. If you want to append a version number you can do so.

wp_enqueue_style( 'polestar-child', get_stylesheet_directory_uri() . '/style.css', array(), '1.0' );

Ref.

For local development, make sure your localhost, MAMP etc. has opcache disabled. In MAMP it's at MAMP > Preferences > PHP > Cache > Off.

liam-moore commented 6 years ago

Hi Andrew,

Getting the child theme to load after the parent theme was giving me the most difficulty so thanks for your help on this (even if this thread turned more into more of a support ticket for other things)! Managed to find out I also wasn't in DEV Mode using Pagely's PressCACHE (rookie mistake) but everything is as it should be now.

Cheers

Misplon commented 6 years ago

Super :) Glad I could help. All the best with your upcoming project. On Tue, Jan 30, 2018 at 4:57 PM liam-moore notifications@github.com wrote:

Closed #1 https://github.com/purothemes/polestar/issues/1.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/purothemes/polestar/issues/1#event-1448718775, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwKp2-zpGI6cwzDMbP0gmRGU7A-JryQks5tPy3lgaJpZM4RyO9T .