I have a theme that includes the stylesheet /css/woocommerce.css This stylesheet is also loaded in the child theme on shop pages. BUT I want to be loaded and on post pages in order to style products that are showed by some plugins. Any advice?



Not tested, by you could try something like the code below. If first register your css as css-woocommerce (yout theme may allready have this) then you can on init use wp_enqueue_style IF it is a post (is_single). Does this help you?

function register_custom_stylesheets() {
    wp_register_style( 'css-woocommerce', 
get_stylesheet_directory_uri() . '/css/woocommerce.css' );

function custom_stylesheet() {
    if ( is_single() { // if is post type, except attachments and pages
        wp_enqueue_style( 'css-woocommerce' ); 
add_action( 'init', 'register_custom_stylesheets' ); 
add_action( 'wp_enqueue_scripts', 'custom_stylesheet' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.