• I want to use a specific stylesheet for one page only and for every other page i want to use the ‘standard’ stylesheet. I have written the code and in my mind, this logically should work but isn’t working.

    The standard stylesheet is style.css and my custom one is style_shop.css. I want the style_shop to be used on the shop page only.

    The current code that specified the stylesheet was in the functions.php page and it said:

    wp_enqueue_style( 'main', get_stylesheet_uri(), 'style');

    So I added my code so it now looks like:

    if (is_page('shop')) {
    	wp_enqueue_style( 'custom-style', get_stylesheet_uri(), 'style_shop.css');
    	}
    	else
    	{
    	wp_enqueue_style( 'main', get_stylesheet_uri(), 'style');
    	}

    In a nutshell, I have a shopping cart (woocommerce) that is visible on every page but as the shop aspect is only a small part of the site I want to make it dissappear on every page other than the shop page.

    style.css displays the cart and style_shop specifies the cart as being ‘display:none;’ hpwever all that is happening is my style_shop.css is just being ignored and the cart remains invisible on the shop page.

    To make things trickier, there is another reference to the main stylesheet further up the functions.php page that says

    $themedata = wp_get_theme(get_stylesheet_directory() . '/style.css');

    I tried adding the if else tags around that first but that had no result either.

    Am I nearly there but just have the code slightly wrong?

Viewing 1 replies (of 1 total)
  • Thread Starter jfarr13

    (@jfarr13)

    Looks like I can’t edit the post but I made 1 mistake above, what I meant to say was:

    style.css specifies the cart as being ‘display:none;’ and style_shop displays the cart as normal.

Viewing 1 replies (of 1 total)
  • The topic ‘Use a specific stylesheet for one particular page’ is closed to new replies.