Styling the Text Widget
Standard image alignment CSS styles such as alignleft, alignright, and aligncenter apply for images.
To specifically style the various default styles of the WordPress Text Widget, use the following example:
<div id=”primary” class=”sidebar”>
<ul>
<li id=”text-1″ class=”widget widget_text”><h3 class=”widgettitle”>Widget Title for First Text Widget</h3>
<div class=”textwidget”>Text within the text widget area.</div>
</li>
<li id=”text-2″ class=”widget widget_text”><h3 class=”widgettitle”>Widget Title for Second Text Widget</h3>
<div class=”textwidget”><p>Text for second widget text area.</p></div>
</li>
</ul>
</div>
Adding Code to the Text Widget
Basic HTML, embeds, and JavaScript are added easily to the WordPress Text Widget. Most embed codes from social sharing sites for multimedia will work in a WordPress Text Widget. However, active code and programming languages such as PHP will not work as the Widget will strip out code it cannot display.
To add active code to the Text Widget, use one of the many WordPress Plugins from the WordPress Plugin Directory that override WordPress restrictions on using PHP in posts. Check that they will work on Widgets as some will not.
Discover more from mycodetips
Subscribe to get the latest posts sent to your email.