A safe way to add/enqueue a CSS style file to the wordpress generated page. If it was first registered with wp_register_style() it can now be added using its handle.

learn more… | top users | synonyms

0
votes
3answers
271 views

Asset loading with gulp.js or Grunt

I just started using gulp.js which is a task runner like Grunt and a lot of the sites I work on are using WordPress so I was wondering if anyone has some ideas about how to use the combined scripts ...
0
votes
2answers
25 views

is there a way to get all queued scripts/styles into a template without `get_header()`?

in my main plugin page i check if a certain page is visited if so, i load a certain template. in the following way: add_filter( 'template_include', array($this, 'includeTemplate'), 99 ); public ...
0
votes
2answers
69 views

Some questions about how proper add 2 CSS file in a WordPress theme?

I have the following situation loading a CSS. I have a WordPress theme that load a style.css settings file by this code into my functions.php file: /* Function automatically executed by the hook: * ...
4
votes
2answers
408 views

Why I can't add a CSS style in this WordPress theme?

I am trying to add a CSS style to a WordPress theme that I am developing as is shown in this tutorial: http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/ ...
0
votes
2answers
130 views

How to make CSS load live based on options clicked in the theme customizer?

I have a problem. I am trying get the theme customizer load a different CSS file based on what radio input in clicked, live! It works so far right now that option is saved when I click "Save & ...
5
votes
1answer
2k views

Enqueue a stylesheet for login page and make it appear in head element

I try to style the login page in my theme. Very simple: add_action( 'login_enqueue_scripts', function() { wp_enqueue_style( 'TEST', get_template_directory_uri() . '/css/login.css' ); }); ...
0
votes
1answer
249 views

Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?

My site's url is set up to include www in settings -> general. I also put it at the very top of my functions.php: update_option('siteurl','http://www.federal-lawyer.com'); ...
1
vote
0answers
386 views

Adding css to wp_head from shortcode

I'm trying to add CSS to wp_head, from within the method called to render a shortcode. I know that wp_head does not take any parameters, so I'm trying to figure out the following: The method called ...
0
votes
1answer
45 views

How to include a file only on dashboard widgets page?

I want to add some styles to the widgets input fields. Therefore I want to include a style.css file only on the wp-admin/widgets.php page. How can I detect the above page and include file there?
0
votes
1answer
88 views

get_template_directory adding FTP root folders in urls

I am creating a theme, and now I am adding some functionality for my custom post type, such as different metaboxes in post page, extra post config page. It seems when I try to get the sites theme ...
1
vote
1answer
835 views

Load custom css after bootstrap

I have this in functions.php. How can I modify it so that my custom css is loaded after bootsrap.min.css? function register_css() { wp_register_style( 'bootstrap.min', ...
0
votes
1answer
31 views

Wordpress include scripts and style in plugin page

I am working on a Wordpress plugin where I want to include some jquery scripts and stylesheet. I found dit piece of code in an article and this should do the job, but it doesn't work for me. Can ...
3
votes
1answer
2k views

Why wp_register_style() is important while I'm using a complete wp_enqueue_style()? [duplicate]

Currently I'm working on a theme, and did some styles and scripts enqueue. When enqueued the scripts, I used wp_register_script() first, and then enqueued with wp_enqueue_script() - because I got ...
1
vote
1answer
61 views

Include user defined styles without including wp-load

I've looked through the answers on here and none quite match my situation. I have custom CSS that a user can edit and it is saved in the options. I use wp_enqueue_style to include a PHP file with a ...
1
vote
2answers
97 views

CSS file not registering through add_action

Im having a problem to register and load a gallery css code from my home page. Rest of the styles are loading fine, but this flexslider is not registering. Any guidance appreciated. <?php ...
0
votes
1answer
89 views

How do you load js and style resources from CDN with local fallback using wp_enqueue_scripts?

I had a hard time finding the correct way to do this. I want to load the CDN resources here: http://www.bootstrapcdn.com/ but use wp_enqueue_scripts and have local fallback. This is the method I am ...
2
votes
1answer
69 views

How to control the order of the combination of enqueued styles and scripts - site speed issue

We know, using wp_head() and wp_footer() all the scripts and styles are enqueued using wp_enqueue_styles and wp_enqueue_scripts hook. What we do is to enqueue our stylesheets and scripts using ...
0
votes
2answers
276 views

Relative path in wp_register_style not working

I have this function: function test_add_my_stylesheet() { wp_register_style( 'test-admin-style', plugins_url('../css/style.css', __FILE__) ); wp_enqueue_style( 'test-admin-style' ); } but ...
1
vote
0answers
16 views

How to enqueue script or style in a theme's template file? [duplicate]

I am making a template for the page which will contain a slider. Can anyone share some advice with me of how to go about it?
1
vote
1answer
233 views

use add_action('wp_head') in a widget

Hi I cant seem to find an answer out there to solve my issue. what i am trying to do is fix this validation error 'Element link is missing required attribute property.' that is occurring because the ...
0
votes
2answers
835 views

Deregister scripts on unnecessary pages using remove_action

To all would-be close-voters: This question is not a duplicate, because I need to remove all scripts added by plugin using remove_action. In Very stubborn wp_register_script / add_action vs ...
0
votes
0answers
39 views

Replacing parent theme's IE-specific CSS

I'm trying to do exactly what was apparently achieved in this discussion. However, I'm finding that my IE-specific stylesheet's being loaded all the time! My parent theme includes this in its ...
2
votes
2answers
3k views

How to override enqueued styles using a child theme

I'm creating a child theme (My first in over 3 years) of a WooCommerce theme and I'm having some trouble with the fact that some of the layout styles are enqueued in the parent theme and I'm having to ...
0
votes
1answer
54 views

Enqueueing Scripts and Styles

I'm trying to enqueue my custom script and style with the block of codes, the scripts works but not the style. I don't know what I'm doing wrong. function my_scripts_method() { ...
0
votes
4answers
88 views

enqueue_style is not working

I try to load the main stylesheet with enqueue_style - but it isn't working. Here is my code from functions.php: function my_scripts() { wp_enqueue_style( 'main-style', ...
0
votes
0answers
55 views

using enqueue_script in a shortcode isn't working

I'm new to wordpress and I'm trying to get this to work by following the wordpress codex but I feel like I must be missing something obvious. I have a child theme based off of a parent one, and I ...
1
vote
3answers
457 views

Avoid to load default WP styles in login screen

Is there some way to avoid the load of default WordPress styles in login screen to only load my custom stylesheets? Actually I'm using this code: function login_styles() { // Sets the styles if ...
1
vote
3answers
183 views

To enqueue or not to enqueue

What is the best way to link to a CSS file in WordPress? Method 1: Use the following whenever needed <link href="<?php echo get_template_directory_uri(); ?>/my-style.css" rel="stylesheet" ...
0
votes
1answer
270 views

Child Theme version is set by parent theme, that isn't correct

I'm using Genesis as my theme framework, and while Genesis is at version 2.0.1, my theme is a different version (1.0). When it adds the style.css line in the header call it is appending the wrong ...
1
vote
3answers
227 views

The best way to add stylesheets to WordPress

I am in the process of converting a mobile responsive page, currently built in Bootstrap into WordPress. Using wp_register_style() and wp_enqueue_style() will add the stylesheets to all pages, ...
0
votes
1answer
146 views

wp_enqueue_style url is trimmed somehow

I am using a plugin that adds a style with wp_enqueue_style(). When I look at the page source I find this line: <link rel='stylesheet' id='ai1ec_style-css' href='http://heseg.com/' ...
0
votes
1answer
72 views

How to enqueue scripts in right way in a plugin?

I am developing a wordpress plugin and just came out with a problem with enqueue scripts. I want to enqueue JQUERY UI (.js) and (.css) in my plugin. Is it better to enqueue it from Google CDN or ...
0
votes
1answer
93 views

wp_enqueue doesn't load dependencies

I'm trying to load style.css but rest.css should be included first. I don't understand why reset.css is not included function addMyScript() { wp_register_style('style', ...
4
votes
3answers
1k views

How to add stylesheets only to pages with specific shortcode?

I'm running a function on pages where the shortcode [make-me-a-map] is used. It enqueues javascript to the page and makes a map. That part works fine (woot!) but I'm having trouble with adding the ...
1
vote
1answer
648 views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
0
votes
1answer
63 views

Checking for 'gallery' shortcode using strpos always returns false

I want to conditionally enqueue a script and stylesheet depending on whether the [gallery] shortcode is used in posts. Here is how I am doing it (based on): function doraemon_scripts() { if( ...
2
votes
3answers
143 views

How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally

I'm building a small gallery plugin and I'd like to only load scripts/styles onto the page IF the gallery has been loaded via the template tag. The template tag can take a post ID parameter when used ...
1
vote
2answers
2k views

How to add dynamic inline style?

I want to add dynamic CSS, so currently I am adding directly to the div, ie: $color = "#000000"; echo '<div style="background:'.$color.'"> Is it bad to add code like above? I have read in ...
1
vote
2answers
71 views

Enqueue never runs

My enqueue scripts are never called I can't figure out why. All my paths are correct and I'm assuming the code is correct Functions.php function tim_enqueue_default_scripts() { if (ENVIRONMENT ...
1
vote
3answers
145 views

Enqueue stylesheets with the same name

Ok, maybe i'm thinking too difficult, but I have 2 stylesheets with the same name. One is from the parent theme folder, and one from the child theme folder. I want to enqueue the style from the child ...
0
votes
1answer
93 views

Why enqueue styles on hook

Why do we need to enqueue styles on a hook, why not just enqueue them straight in like this? wp_enqueue_style( $handle, $src); the codex page gives an example of using a hook but doesn't explain ...
1
vote
1answer
228 views

Removing an action, or dequeueing style - Both not working

What I am wanting to achieve is to remove an action called inside of another action. The action is calling a style, and although I have tried to deregister, and dequeue the style, it is still ...
1
vote
1answer
203 views

How can I let templates choose which stylesheets are enqueued?

My theme's functions.php hooks into wp_enqueue_scripts to register a couple of stylesheets that are used by various site pages. Here's a simplified version of my configuration: ...
5
votes
1answer
4k views

How to enqueue style before style.css

How do I enqueue a .css file before style.css is loaded? Or make the default style.css dependant on another .css file? I'm trying to load a .css reset, which style.css would overwrite. Here's what I ...
0
votes
2answers
84 views

wp_enqueue_scripts hangs

In the following snippet, when I add the wp_enqueue_scripts call, the page freezes. What am I doing wrong? function my_enqueue_stuff() { if ( is_front_page() ) { wp_enqueue_style('style', ...
1
vote
0answers
59 views

How to load script-related styles automatically?

Scenario: It is common that a JS dependency is bundled with a style file to work properly (just think about your favorite slideshow jQuery plugin). AFAIK, in this situation, the script and style have ...
1
vote
1answer
410 views

wp_enqueue_style will not let me enforce screen only

I am using Roots as the starter for a theme I have been working on. I then generated a print.css file, but in Chrome's case, it still is using the bootstrap-responsive.css queries, and messing things ...
0
votes
1answer
2k views

get_stylesheet_uri returns wrong path

I am using the roots theme. Inside scripts.php, the stylesheets are loaded using the wp_enqueue_style-function. wp_enqueue_style('roots_bootstrap', get_template_directory_uri() . ...
1
vote
1answer
461 views

wp_enqueue_script Doesn't Work?

It's pretty standard, I enqueue script and style for admin page. function admin_custom(){ wp_enqueue_script('js', plugins_url('adm.js', __FILE__)); wp_enqueue_style('css', ...
0
votes
2answers
109 views

Display Something in the Header After All Styles are Loaded

I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a <style> in the header after ALL ...