How to reference CSS file in wordpress custom pages

| Muhammad Yaseen

We can add or reference our CSS file into Word Press custom pages in many ways, we will discuss two of them in this blog.

But keeping in mind we cannot simply use this <link rel="stylesheet" href="mystyle.css">.

First method,

Rather than loading the style sheet in your header file, you should load it in using wp_enqueue_style. In order to load your main style sheet, you can en-queue it in functions.php file.

To en-queue style.css

This will look for a stylesheet named “style” and load it.

The basic function for en-queuing a style is:

You can include these parameters:

  • $handle is simply the name of the style sheet.
  • $src is where it is located. The rest of the parameters are optional.
  • $deps refers to whether or not this style sheet is dependent on another style sheet. If this is set, this style sheet will not be loaded unless its dependent style sheet is loaded first.
  • $ver sets the version number.
  • $media can specify which type of media to load this style sheet in, such as ‘all’, ‘screen’, ‘print’ or ‘handheld.’

So if you wanted to load a stylesheet named “slider.css” in a folder named “CSS” in you theme’s root directory, you would use:

Second method, To add CSS file, just link the file in the header. Using get_stylesheet_directory_uri () function

Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.

Chief Architect, Founder, and CEO - a Microsoft recognized Power Platform solution architect.

About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.

More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting