{"id":42968,"date":"2020-02-27T20:30:57","date_gmt":"2020-02-27T15:00:57","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=42968"},"modified":"2021-01-05T16:42:54","modified_gmt":"2021-01-05T11:12:54","slug":"bootstrap-font-awesome-in-wordpress-visual-post-editor","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2020\/02\/bootstrap-font-awesome-in-wordpress-visual-post-editor\/","title":{"rendered":"Import Bootstrap CSS, Font Awesome Icons in WordPress Visual Post Editor"},"content":{"rendered":"<p>How can you view Bootstrap CSS styles and Font awesome icons in your WordPress visual post editor? Currently, if you use these 2 <a title=\"5 Essential Web Design Elements You Must Use\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/09\/essential-web-design-elements\/\">essential design elements<\/a>, the changes are not visible in the WordPress visual post editor, and you need to preview the post live to see the changes. This makes effective implementation difficult as you need to constantly keep switching. Is there an easier way?<\/p>\n<h2>Import Bootstrap CSS \/ Font Awesome Icons<\/h2>\n<p><a title=\"Use Twitter Bootstrap for Powerful Web Design\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/07\/twitter-bootstrap\/\">Bootstrap<\/a> is the best front end mobile-first tool to develop great responsive websites, and we now use it on all our website designs. <a title=\"How to Add Icon Font Awesome to Any Site\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/07\/add-icon-font-awesome\/\">Font Awesome<\/a> is a great icon font that loads super fast and is a useful way to replace all icons and icon images on your site. <span style=\"font-weight: 400;\">If you use Bootstrap Themes like <a href=\"https:\/\/www.quickonlinetips.com\/archives\/quickstrap-wordpress-theme\/\">Quickstrap<\/a>, you will realize that you see in the WordPress post editor is actually not what is displayed on the live website once the post is saved or updated.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\"> For example, I really cannot make out the blockquote test as it appears similar to the other post text. <\/span><span style=\"font-weight: 400;\">So how can you get the WordPress visual editor to display bootstrap CSS or add Font Awesome icons such that the styling appears similar to what it would appear in the actual post?\u00a0<\/span><\/p>\n<p>For example, here is what we are trying to do &#8211; \u00a0insert a simple button powered with both tools. The button is drawn by Bootstrap and the thumbs up icon by Font Awesome.<\/p>\n<pre><code>&lt;span class=\"btn btn-lg btn-success\"&gt;\r\n&lt;i class=\"fas fa-thumbs-up\"&gt;&lt;\/i&gt; LIKE\r\n&lt;\/span&gt;<\/code><\/pre>\n<p>This is how typically this code would like in your WordPress Visual Post Editor<\/p>\n<p><img decoding=\"async\" class=\"border alignnone wp-image-42974 size-full\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/nostyle-wordpress-editor.png\" alt=\"nostyle wordpress editor\" width=\"333\" height=\"187\" border=\"1\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/nostyle-wordpress-editor.png 333w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/nostyle-wordpress-editor-150x84.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/nostyle-wordpress-editor-300x168.png 300w\" sizes=\"(max-width: 333px) 100vw, 333px\" \/><\/p>\n<p>And this is how it looks like in my Visual Post editor right now.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42975\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/bootstrap-wordpress-editor.png\" alt=\"bootstrap in wordpress editor\" width=\"326\" height=\"207\" border=\"1\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/bootstrap-wordpress-editor.png 326w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/bootstrap-wordpress-editor-150x95.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/bootstrap-wordpress-editor-300x190.png 300w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/p>\n<h2>Add Editor Styles<\/h2>\n<p><span style=\"text-decoration: underline;\"><strong>Step 1<\/strong><\/span>\u00a0&#8211; First you need to <strong><a title=\"How to Add Custom CSS Styles to WordPress Post Editor\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2020\/02\/add-custom-css-wordpress-post-editor\/\">add editor styles<\/a><\/strong> step-wise as I explained in the last post. Then if you have used that post tips to enable the custom styles for your post editor, then I assume you already have the WordPress function in <strong><em>functions.php<\/em><\/strong> in place and a <strong><em>custom-css-styles.css<\/em><\/strong> file in place.<\/p>\n<h2>Import Bootstrap CSS<\/h2>\n<p><span style=\"text-decoration: underline;\"><strong>Step 2<\/strong><\/span> &#8211; <span style=\"font-weight: 400;\">So here is the fix that based on a similar example in the previous article, that you basically need to <strong>import the CSS URL<\/strong> into the <strong>editor stylesheet. <\/strong><\/span><\/p>\n<pre>@import url(\"https:\/\/sitename.com\/wp-content\/themes\/themename\/css\/bootstrap.min.css\");\r\n@import url(\"https:\/\/sitename.com\/wp-content\/themes\/themename\/font-awesome\/css\/all.css\");<\/pre>\n<h2>Clear WordPress Cache<\/h2>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\"><strong>Step 3<\/strong><\/span> &#8211; After you save the changes, it is very important to clear your browser cache as well as clear the WordPress cache, else you will notice no changes!\u00a0 After that, once you reload the WordPress editor again, you will see the similar Bootstrap or Font Awesome Icons or custom styling as that on your website. Simple. Done!<\/span><\/p>\n<h3>Fix for Bootstrap CDN?<\/h3>\n<p>Many bloggers like to use <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2015\/09\/fastest-cdn-jquery-bootstrap\/\">free CDN<\/a> to import Bootstrap CSS or Font Awesome CSS. You can use their CDN URLs instead of linking to CSS on your site server for faster load times. For example.<\/p>\n<pre>@import url(\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.4.1\/css\/bootstrap.min.css\");<\/pre>\n<p>Now when you place Bootstrap code or Font Awesome in your WordPress posts, you need not preview it every time, simply view it live in your WordPress Post editor. Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can you view Bootstrap CSS styles and Font awesome icons in your WordPress visual post editor? Currently, if you&#8230;<\/p>\n","protected":false},"author":4,"featured_media":42975,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[49,17],"class_list":["post-42968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/42968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=42968"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/42968\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/42975"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=42968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=42968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=42968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}