Pretty print fractions as HTML entities using PHP

David Nash code, html, php 1 Comment

I used this code in a WordPress site but it’s pure HTML. I wanted to take a string, for example “3/4” and convert it to a HTML entity ¾. When there’s no HTML entity I still wanted it to look nice, using <sup> and <sub> for the numerator and denominator respectively. I couldn’t find anything on the web that I could copy and paste so I wrote it myself. Here’s what I came up with:

It’s pretty straight forward. First we check that the string is of the form X/Y. We put the X and Y into an array, …

Appearance Customize example code

Appearance Customize – WordPress theme Quick Start

David Nash code, wordpress 0 Comments

There’s a lot of detailed information on how to add settings under the WordPress Appearance Customize menu. It’s far too detailed if you just want to add a couple of settings. In this example I just wanted to add some simple fields. One for the company title, which differs from the site title. And another for their logo which appears in the WordPress header. Modifying Appearance Customize with functions.php

Once you add this, check under Appearance > Customize. If all is well you’ll see your logo and title field. If you’re really adventurous you could create an array of …