Questions tagged [wp-enqueue-style]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

How to enqueue additional scripts and styles after loading another post into the DOM?

If have a post_showcase shortcode that takes in post_ids as parameters. The shortcode generates buttons that when click will load the given post into a modal. However, the shortcodes within the ...
Gus Beringer's user avatar
1 vote
0 answers
12 views

Load RTL CSS using block.json for block development

I am developing a block using block.json and I could load RTL CSS on backend using this code: // Check if RTL mode is enabled if (wp.i18n.isRTL()) { // Import RTL stylesheet if RTL mode is enabled ...
Farhad Sakhaei's user avatar
0 votes
1 answer
59 views

Enqueue Stylesheet on the front end and in the block editor Conditionally

How would you include a stylesheet in both the block-editor and on the front-end if the page meets certain criteria? In this case I want to include a stylesheet called homepage.css if the page is the ...
Walrus's user avatar
  • 131
1 vote
1 answer
17 views

login_enqueue_scripts changes are not reflecting

I tried adding a custom CSS for my wp-login page and login forms within my website using the login_enqueue_scripts hook. My issue is that my changes don't initially reflect on the front end. But the ...
Nalin Vyas's user avatar
0 votes
0 answers
22 views

admin_enqueue_scripts not load custom scripts from cdn

I have this code in a plugin class DashboardCustomizer { public function __construct() { add_action( 'admin_enquque_scripts', array( $this, 'load_custom_scripts' ) ); } /* ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
36 views

Javascript isn't loading when I use wp_enqueue_script, but CSS is when I use wp_enqueue_style

functions.php: function filmstarrrr_files() { wp_enqueue_script('filmstarrrr-main-script', get_theme_file_uri('/build/script.js'), NULL, '1.0', false); wp_enqueue_style('...
1mayersz's user avatar
0 votes
2 answers
47 views

Correct way to enqueue js and css for external php scripts

I am developing a plugin that uses some external PHP library. That PHP library uses js and CSS. I want to enqueue that external library js and CSS using the Wordpress enqueue functions in Wordpress ...
SDeveloperj's user avatar
0 votes
1 answer
168 views

functions.php doesn't load all custom theme assets

I'm writing a simple wordpress theme. I've added this function inside the functions.php file and I've noticed that only style.css is loaded. Is there something wrong that will cause that the other ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
25 views

Styling best practices for single pages/templates

What's the best practice for CSS that is specific to one PHP file? For example, let's say I make a page page-456.php that is styled differently from the rest of the site, what's the best practice to ...
Coopero's user avatar
  • 101
0 votes
1 answer
61 views

wp_head not injecting css

I'm trying to inject a style.css script into my front-page.php. None of the styles load. In the tutorials, when you inspect page source, all the CSS should be there, but it simply shows the wp_head() ...
Shawn Esquivel's user avatar
0 votes
2 answers
256 views

How enqueue CSS out of theme folder?

How we can enqueue a stylesheet out of theme folder? Example: wp-content > cssfile.css
015ra's user avatar
  • 9
0 votes
1 answer
40 views

plugin not loading my css and js

Hi I'm using the standard way to load styles and scripts within my plugin. But I have no clue why it's not working. It's not shown in the network tab nor in the <head>. Can this cause issues ...
Jan's user avatar
  • 33
0 votes
1 answer
48 views

How to fix enqueue_styles error for a twenty-seventeen childtheme

I have searched your site but cannot find and fix this error I get: Notice: Function wp_enqueue_style was called <strong>incorrectly</strong>. Scripts and styles should not be registered ...
Prink1978's user avatar
0 votes
1 answer
67 views

How do I remove Google Fonts from a parent theme?

I'm using the theme Pixgraphy and created a child theme. Because of recent changes concerning data protection in the EU, I now want to load Google Fonts locally. The parent theme includes the Google ...
TheKidsWantDjent's user avatar
0 votes
1 answer
179 views

Why do WordPress adds the id="handle-{js|css}" attribute to scripts and stylesheet?

When you enqueue a script the id="" attribute and the script handle (appended with the -js or -css termination) are automatically added to the generated <script> or <style> tag. ...
amarinediary's user avatar
0 votes
1 answer
79 views

Stylesheet version not showing in browser when adding version number to stylesheet in enqueue

I'm trying to figure out why I'm not seeing the stylesheet version number is my browser, when I add the version number to the enqueue function, where I enqueue the stylesheet. Here's the code: ...
Jillian Hoenig's user avatar
0 votes
1 answer
91 views

Custom theme – Bootstrap CSS not loading via wp_enqueue_style or otherwise

I'm designing a custom Theme using the underscores.me template. I've read several different "my css doesn't load" articles on this topic, but none seem to help w/ my issue. My own styles ...
Sylvester DeMouser's user avatar
0 votes
1 answer
179 views

Enqueue MCE Editor CSS in admin page

I am using mce editor for some formatted content. That content is stored in metadata. Now when I render the content it does render the content but the styles for the contents are missing like "...
MrCoderAndEditor's user avatar
0 votes
1 answer
246 views

How to add/enqueue Custom CSS for a custom taxonomy page?

So this is what I have done for my homepage so I load css that only loads on my homepage function enqueue_frontend_assets(){ if(is_page_template( 'homepage.php')) { wp_enqueue_style( '...
fjimenez's user avatar
0 votes
1 answer
38 views

str_replace inside specific css files [closed]

Is it possible to perform str_replace inside an enqueue stylesheet? i can do str_replace on inline style with this function function replace_text($text) { $text = str_replace('background-image', '...
Uxair's user avatar
  • 1
1 vote
0 answers
176 views

How to override Bootstrap css with my child theme css in wordpress?

I am trying to load my site's child theme's css after Bootstrap CDN css in wordpress. I tried using these code but it doesn't work. The Bootstrap css is not overriden. What should I do to fix that? ...
wcwc's user avatar
  • 11
0 votes
1 answer
27 views

Add wp_add_inline_style into another wp_add_inline_style for better performance

function loadOneStylePage(){ wp_enqueue_style( 'main-style', get_template_directory_uri() . '/styles/main.css', array(), _S_VERSION ); wp_enqueue_style( 'main-style-separate-file', ...
Art's user avatar
  • 1
0 votes
1 answer
2k views

Adding google fonts to WordPress theme

I am trying to add google fonts to a custom WordPress theme. Therefore I tried to enqueue selected three font faces at once to make it fast loading. So, I use the below codes to register and enqueue ...
user2584538's user avatar
1 vote
0 answers
167 views

Load CSS before Theme CSS

I have a stylesheet I want to load first in the head before other plugins load css or theme css. For some reason priority is not working for me. Any idea how I can achieve this? I need to use ...
Ads's user avatar
  • 11
1 vote
0 answers
104 views

How to check if a WordPress core block is active in sidebar

I have a widget area and I want to enqueue a stylesheet only if a core block is active in it. I tried the following code: // if has audio block. if (has_block('audio')) { wp_enqueue_style('audio-...
Zeddy Emy's user avatar
1 vote
1 answer
456 views

Enqueue scripts not working with if is page conditional tag in functions.php

Is this even the correct way of including scripts on a specific page? function insert_mapsvg_scripts() { wp_enqueue_style( 'mapsvg_css', site_url('/mapsvg/css/mapsvg.css') ); wp_enqueue_style( '...
Biels's user avatar
  • 113
2 votes
1 answer
1k views

Enqueue styles in new site editor in WordPress 5.9

In the block editor for posts and pages, I used to use the enqueue_block_editor_assets hook to enqueue styles for the block. add_action( 'enqueue_block_editor_assets','load_assets_in_block' ); ...
Sanzeeb Aryal's user avatar
0 votes
1 answer
275 views

How To Load wp_add_inline_styles

I'm using this PHP code to modify default CSS inline via functions.php however its not working. <?php add_action( 'wp_enqueue_scripts', 'inline_bar_width' ); function inline_bar_width() { if (...
Brad Dalton's user avatar
  • 6,896
0 votes
1 answer
55 views

What is the colors handle from WordPress core for and why does it not have a path?

Looping through $wp_styles->registered, the handle colors is outputted with a $wp_style->src of 1. Searching through WordPress core, it isn't immediately clear what it's for. The code is: ...
Motivated's user avatar
  • 205
0 votes
1 answer
2k views

Can only override parent theme styling with '!important' in child style.css

function my_theme_enqueue_styles() { wp_enqueue_style( 'twentytwentyone-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', ...
BeccaN's user avatar
  • 17
0 votes
0 answers
198 views

Filter enqueued styles and scripts

I am looking for a way to reorganize the scripts/styles queue in WP. I am well aware of the fact altering the queue may have undesired effects, but in this case there are solid reasons for doing it ...
Álvaro Franz's user avatar
0 votes
1 answer
122 views

Enqueue CSS on custom posts' backend area

I'd like to insert some CSS on a specific post type's backend area. So not globally. I've found lots of ways to insert it everywhere, but can't figure out how you'd target posts only. Any ideas?
Fluxian's user avatar
  • 130
0 votes
1 answer
34 views

Why would the child theme load in the Customize preview, but not on the site itself?

I have my child theme folder, the style.css sheet with the required template comment and some custom css, and I have the functions.php page with the required enqueing code. Everything seems to be in ...
Benjamin Jex's user avatar
0 votes
0 answers
141 views

Advanced method to control cache of enqueued style/script

I have a WordPress website with medium-level traffic, ~10,000 unique visitors a day. Arround 30% of my daily visitors are recurrent. I constantly make some UI improvements: colors, font-size, ...
Alexandro Giles's user avatar
0 votes
1 answer
970 views

make admin.css in my child theme

i want hide elements of admin with css file "my-admin.css" I put css file "my-admin.css" at the root of my child theme wordpress and use this code in functions.php but does not ...
Calachuka's user avatar
0 votes
1 answer
53 views

Custom WordPress Theme loads js but not stylesheets

I have looked around as best I could, but I could not find a solution to this problem. I am building a custom WordPress template from scratch and the stylesheets won't load. For some reason, the ...
N.MORR's user avatar
  • 113
2 votes
3 answers
2k views

Enqueue script o style only if a template part is loaded

I have registered some styles and scripts that should be loaded if a template part is loaded in a template file. For ex: in home.php <?php get_template_part( 'template-parts/external_links'); ?> ...
Alexandro Giles's user avatar
0 votes
0 answers
48 views

Creating a WP plugin and having issues linking CSS stylesheet within functions

Creating a WP plugin for third party usage (first time doing this), and typically links to stylesheets are put in the header or in the theme generated options panel. That's fine for personal use but ...
Jwrbloom's user avatar
2 votes
1 answer
1k views

.editor-styles-wrapper overriding my block styles in Gutenberg

I'm working on my first theme built from custom gutenberg blocks. I've managed to register blocks and enqueue their specific stylesheets, but I'm running into one issue that's kind of a pain. A lot of ...
AGKlem's user avatar
  • 41
0 votes
0 answers
187 views

Why does using wp_register_style without wp_enqueue load and print CSS tags in the front-end?

I have this piece of code that registers a CSS in a child theme and when visiting the front-end my_css is actually included. Why is that ? I thought that registering meant registering for later use to ...
John Christopher's user avatar
0 votes
1 answer
195 views

How to add styles to a submenu page?

I'm relatively new to WordPress and, I am creating this plugin, where I need a submenu page. I have successfully created the main page and have added CSS to it without any problems. However, I came to ...
Vitor Rodrigues's user avatar
1 vote
1 answer
117 views

Is my approach to enqueue styles inefficient?

I'm kinda new to wordpress and programming in general. I have the following question. Recently I came across this article and wanted to use this approach in the wordpress theme I'm working on. I wrote ...
sabbir ahmed's user avatar
1 vote
0 answers
139 views

How to enqueue JavaScript file that depends on CSS stylesheet

I'm trying to set up a build process for JS/CSS assets to work with my WordPress theme. In my JavaScript file, I can do this: // src/button.js import React from 'react'; import './Button.css'; ...
Dan's user avatar
  • 143
1 vote
1 answer
749 views

How to remove plug in styles for WPForms Lite [closed]

I would like to remove the preset style sheets that WPForms Lite applies to its forms. So that I can use my own and not have to cause excess bloat by overriding the preset stylesheet. Currently, I ...
UntitledGraphic's user avatar
0 votes
1 answer
245 views

Dequeue styles with query doesn't work

In my theme there is the following code (that is printing some inline css on the head of my site) final class Design_Scheme { /** * Design_Scheme constructor. */ private function __construct() { ...
Honoluluman's user avatar
0 votes
1 answer
24 views

theme style is applied on the dhasboard rather than the website

I am creating a new theme, I created a new directory called mytheme and created three files directly inside the directory where the content is as follow: index.php <?php echo "hellow world&...
user avatar
0 votes
1 answer
585 views

Add custom css file after plugin css with Wordpress Child Theme functions.php

I am trying to enque a css file thorugh my child themes functions.php after a specific plugin css file with the handle openpos.bill.bootstrap. Unfortunately the current code does not load anything. ...
evavienna's user avatar
  • 131
0 votes
2 answers
193 views

Which is the correct way to conditionally enqueue a CSS file?

get_queried_object returns NULL inside a function hooked to wp_enqueue_scripts action hook when going to an nonexistent category URL on my website. If the category exists, the error is not shown and I ...
silviubogan's user avatar
0 votes
1 answer
536 views

How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)

I’ve created a plugin for my child theme, in which custom functions are stored. Additionally, within the plugin, I'm also enqueueing stylesheets and .js which control the output of two templates, for ...
Nate's user avatar
  • 15
0 votes
1 answer
161 views

How to add CSS via custom plugin?

I am making my first plugin. I create a folder in \wp-content\plugins, create a test.css and a test.php file. Here is my test.css: body { background-color: red !important; } Here is my test.php (...
Ooker's user avatar
  • 330

1
2 3 4 5
12