{"id":843,"date":"2019-01-07T11:39:56","date_gmt":"2019-01-07T06:09:56","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=843"},"modified":"2019-01-07T11:39:56","modified_gmt":"2019-01-07T06:09:56","slug":"how-to-enqueue-stylesheet-and-scripts-in-wordpress","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/","title":{"rendered":"How to enqueue stylesheet and scripts in WordPress?"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Nowadays,\u00a0WordPress is widely used for creating user interactive websites. WordPress is a free and open source CMS (Content Management System) based on PHP, MySQL. Though it is mainly used for blogging\u00a0but also supports other types of websites including online stores, informative sites, mailing lists, and forums.<\/p>\n<p>WordPress comes with its own default themes, but one can also install and switch other themes. With the help of themes, WordPress users can change the feel and look of the website, without changing the content. Another important feature of WordPress is plugins.<\/p>\n<p>Users can add appropriate plugins to their sites by installing it from the dashboard. And after installation, it needs to be activated then only that particular plugin will be visible in the WordPress dashboard.<\/p>\n<p>WordPress users can also create their own custom theme and give a creative look to their website. For that, the user may need to add the additional stylesheet and javascript files in the theme. So, here are the full details of enqueuing stylesheet and javascript.<\/p>\n<p><em><strong>The Method:<\/strong><\/em><\/p>\n<ol>\n<li><strong>To enqueue styles and JS libraries, go to functions.php\u00a0file.\u00a0<\/strong><\/li>\n<li><strong>Enqueue the script using\u00a0wp_enqueue_script()\u00a0or enqueue the style using\u00a0wp_enqueue_style()<\/strong><\/li>\n<\/ol>\n<p><em><strong>Example :<\/strong><\/em><\/p>\n<p>To enqueue style in functions.php<\/p>\n<p><strong>wp_enqueue_style( &#8216;custom-css&#8217;, get_template_directory_uri() . &#8216;\/css\/custom.css&#8217;,false,&#8217;1.1&#8242;,&#8217;all&#8217;);\u00a0<\/strong><\/p>\n<p>To enqueue script in functions.php<\/p>\n<p><strong>wp_enqueue_script( &#8216;script&#8217;, get_template_directory_uri() . &#8216;\/js\/script.js&#8217;, array ( &#8216;jquery&#8217; ), 1.1, true);<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Nowadays,\u00a0WordPress is widely used for creating user interactive websites. WordPress is a free and open source CMS (Content Management System) based on PHP, MySQL. Though it is mainly used for blogging\u00a0but also supports other types of websites including online stores, informative sites, mailing lists, and forums. WordPress comes with its own default themes, but [&hellip;]<\/p>\n","protected":false},"author":30,"featured_media":851,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,18,5],"tags":[33,43,75],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to enqueue stylesheet and scripts in WordPress?<\/title>\n<meta name=\"description\" content=\"Nowadays,\u00a0WordPress is widely used for creating user interactive websites. WordPress is a free and open source CMS (Content Management System)...\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to enqueue stylesheet and scripts in WordPress?\" \/>\n<meta property=\"og:description\" content=\"Nowadays,\u00a0WordPress is widely used for creating user interactive websites. WordPress is a free and open source CMS (Content Management System)...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-07T06:09:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2018\/12\/banner.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2018\/12\/banner.jpg\",\"width\":1024,\"height\":500},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/\",\"name\":\"How to enqueue stylesheet and scripts in WordPress?\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/#primaryimage\"},\"datePublished\":\"2019-01-07T06:09:56+00:00\",\"dateModified\":\"2019-01-07T06:09:56+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/a0964abd0123c3921478c855abf08c11\"},\"description\":\"Nowadays,\\u00a0WordPress is widely used for creating user interactive websites. WordPress is a free and open source CMS (Content Management System)...\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/how-to-enqueue-stylesheet-and-scripts-in-wordpress\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/a0964abd0123c3921478c855abf08c11\",\"name\":\"Aheli Bharadwaj\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fa8d1449e4d157d4013e9b67ce92f60f?s=96&r=g\",\"caption\":\"Aheli Bharadwaj\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/843"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=843"}],"version-history":[{"count":5,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/843\/revisions"}],"predecessor-version":[{"id":912,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/843\/revisions\/912"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/851"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}