Include print style sheet

Use wp_enqueue_style to add a print stylesheet, note the media parameter that lets you make it a print-specific stylesheet: function wpa_print_styles(){ wp_enqueue_style( ‘wpa-print-style’, get_stylesheet_directory_uri() . ‘/print-style.css’, array(), ‘20130821’, ‘print’ // print styles only ); } add_action( ‘wp_enqueue_scripts’, ‘wpa_print_styles’ );

Woocommerce include custom stylesheet after woocommerce styling [closed]

wp_enqueue_style supports dependencies. So, if you make the WooCommerce style a dependency for your new stylesheet then your stylesheet will always load after the WooCommerce stylesheet. Something like this ought to work, but it is untested: function enqueue_style_after_wc(){ $deps = class_exists( ‘WooCommerce’ ) ? array( ‘woocommerce-layout’, ‘woocommerce-smallscreen’, ‘woocommerce-general’ ) : array(); wp_enqueue_style( ‘my-style’, ‘my-style.css’, $deps, … Read more

Sticky navigation and the wpadminbar

You should be able to keep the wpadminbar from overlaying your navigation bar by using either JavaScript or a combination of PHP and CSS. I would add this php to the header.php file of your theme: <?php if ( is_admin_bar_showing() ) { ?> <style> .my-nav-bar { position: absolute; top: [wpadminbar-height]px; } </style> <?php } ?> … Read more

current-menu-item class not working

This is happening because the menu item is created with the page page “books”, but the page currently displayed is post-type-archive-books (see classes in the body and menu item list). You can use something like function add_nav_menu_classes($classes, $item) { if (is_post_type_archive(‘books’) && ($item->title == “Books”)) { $classes[] = ‘current-menu-item’; } return $classes; } add_filter(‘nav_menu_css_class’ , … Read more

Assets in css dont link properly in pages other than home

You’re using relative URLs that will always look inside the current URL structure. You either need to add a slash before wp-content, or put in the full URL to the resources. So for example: src: url(‘/wp-content/themes/mytheme/fonts/font.ttf’); or src: url(‘http://example.com/wp-content/themes/mytheme/fonts/font.ttf’);

How to dequeue styles coming from plugins?

You’re on the right track, but you need to know the stylesheet’s ID. It’s not necessarily the same as the stylesheet’s filename. Check the generated source of your page (ie, load the page up in a browser and View Source). Find the <link> tag that’s loading the stylesheet. If it’s been properly enqueued for WordPress, … Read more