calling an additional css and js links for a custom page template

wp_register_script( $handle, $src, $deps, $ver, $in_footer ); wp_register_style( $handle, $src, $deps, $ver, $media ); if (!is_admin()) { add_action(‘wp_enqueue_scripts’, ‘my_js’); // for js add_action(‘wp_enqueue_scripts’,’my_style’); // for css } function my_js(){ if(is_page(page id)){ // or is_page_template(page slug) wp_register_script( ‘port-js’, get_template_directory_uri() . ‘/portfolio-js.js’); wp_enqueue_script( ‘port-js ‘); } } function my_style(){ if(is_page(page id)){ // or is_page_template(page slug) wp_register_style( ‘port-style’, … Read more

Loading bbPress CSS file only on forum directory

The styles are enqueued in the function enqueue_styles() inside the file /wp-content/plugins/bbpress/templates/default/bbpress-functions.php. It’s a matter of using is_bbpress() and wp_dequeue_style. Only one of the styles is enqueued, but here we’re removing all 3 possibilities. add_action( ‘wp_enqueue_scripts’, ‘bbpress_enqueue_wpse_87081’, 15 ); function bbpress_enqueue_wpse_87081() { // Check if bbpress exists if( !function_exists( ‘is_bbpress’ ) ) return; if( !is_bbpress() … Read more

Using variable to display a page with a different stylesheet

if the url is www.example.com/page?style=alt, you can conditionally check the presence of $_GET[‘style’] when you’re including your styles. Add the following where you are enqueueing your syles(probably in functions.php): if(isset($_GET[‘style’]) && $_GET[‘style’]==’alt’){ wp_enqueue_script(‘alternate_style); else{ wp_enqueue_script(‘normal_style); }

define css class in functions.php

First off, the origin of the data (WordPress theme options) aside, this question is pretty much about generic PHP and CSS. That being said, here’s how: PHP Stylesheet Add a new file to your theme, call it “dynamic_styles.php” or the like. Note that while it will contain mostly CSS, you give it a .php file … Read more

Style product detail page with custom CSS in woocommerce

Try adding classes, instead of restricting the CSS to certain pages. You should be looking for classes that will allow you to apply your styles to those pages only. Usually the CSS for the entire site will be loaded at once and kept in the cache. So don’t try to load the styles only on … Read more