how to include other plugins css files in a shortcode?

I think you could get around this by pre-running the shortcodes on the page by applying the content filters before the header is output. This should allow any internal shortcodes run inside the included post to add any action hooks properly and thus any needed stylesheets/resources. add_action(‘wp_loaded’,’maybe_prerun_shortcodes’); function maybe_prerun_shortcodes() { if (is_page()) { global $post; … Read more

Remove wp_add_inline_style

Remove styles added with wp_add_inline_style() If we want to keep the custom-style-css but only remove the custom-style-inline-css, then we can try e.g. add_action( ‘wp_print_styles’, function() { // Remove previous inline style wp_styles()->add_data( ‘custom-style’, ‘after’, ” ); } ); where after is data key for the inline style corresponding to the custom-style handler. There is exists … Read more

wp_enqueue_style for Plugin with multiple stylesheets

To answer your first question, you would use the second style, i.e. function add_my_stylesheet() { wp_enqueue_style( ‘myCSS’, plugins_url( ‘/css/myCSS.css’, __FILE__ ) ); wp_enqueue_style( ‘myCSS1’, plugins_url( ‘/css/myCSS1.css’, __FILE__ ) ); } add_action(‘admin_print_styles’, ‘add_my_stylesheet’); What the add_action() function does is tell WordPress, “When the admin_print_styles action occurs, run this add_my_stylesheet() function.” Confusingly, the practice of using the … Read more

Get list of scripts / styles and show file which enqueued them

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there’s no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names. The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts(): … Read more

Load js/css files only on specific admin UI pages

The right hooks // Use both for scripts & styles *) wp_enqueue_scripts // (for the frontend) login_enqueue_scripts // (for the login screen) admin_enqueue_scripts // (for the admin dashboard) *) Read this article @wpdevel. Further reading in the Codex about the three hooks admin_menu network_admin_menu user_admin_menu On the admin_enqueue_scripts hook, you have an argument as well: … Read more

Enqueue custom font file with rel=”preload”

You could try using the style_loader_tag filter. add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); function my_enqueue_scripts() { wp_enqueue_style(‘my-style-handle’, “https://wordpress.stackexchange.com/fonts/custom-font-folder/CustomFontFile.woff2”, array(), null); } add_filter(‘style_loader_tag’, ‘my_style_loader_tag_filter’, 10, 2); function my_style_loader_tag_filter($html, $handle) { if ($handle === ‘my-style-handle’) { return str_replace(“rel=”stylesheet””, “rel=”preload” as=”font” type=”font/woff2″ crossorigin=’anonymous'”, $html); } return $html; } Here we’re enqueuing the stylesheet using the normal wp_enqueue_style function. We then capture the … Read more

Loading a child-theme’s style.css after the parent’s

As @Andy Macaulay-Brook pointed out WordPress doesn’t load child-theme’s style.css . I guess parent theme might be en-queuing it. De-queue the child-theme style.css first and then enqueue it En-queue parent’s style.css before child theme’s style.css De-queue the child-theme style.css You can de-queue the child-theme’s style.css by using the handle.You can find out the handle either … Read more