Home>Support>register_frontend_styles to footer

register_frontend_styles to footer

Im making my own modules to page builder.
It is possible to load CSS in footer like JS files?

Im trying to find this in plugin sorce code, but I can’t found.
It is possible to set globaly for all widgets?

function initialize()
				    $this->so_plugin_url . 'tpl/script.js',
                                    true // add to fotter

			    array($this->so_plugin_slug, $this->so_plugin_url . 'tpl/main.min.css', array(), self::SO_PLUGIN_VER),

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 1 year, 2 months ago Alex S Hi, I Work Here


    register_frontend_styles is a helper function for wp_enqueue_style. This function doesn’t work in the same way as wp_enqueue_script so it’s not possible to tell WordPress to output the script to the footer when registering them.

    You could override enqueue_frontend_scripts and hook into wp_footer and output your CSS there. You’ll need to do this for each widget however as this method – and related styling – is widget specific.

    Kind regards,

  2. 1 year, 2 months ago fpweb

    hmm something like this in my widget?

    function enqueue_frontend_scripts( $instance ) {
    		$this->enqueue_registered_scripts( $instance );
    		add_action('get_footer',  $this->enqueue_registered_styles( $instance));
    		do_action('siteorigin_widgets_enqueue_frontend_scripts_' . $this->id_base, $instance, $this);
  3. 1 year, 2 months ago Alex S Hi, I Work Here

    Hi Fpweb,

    I recommend using wp_footer instead of get_footer. You add a hook for get_footer and then use $this->enqueue_registered_styles( $instance).

    Kind regards,

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More