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, …

Use curl and PHP Simple HTML DOM Parser to inject WordPress into another page

David Nash css, html, php, wordpress 3 Comments

I was recently asked to create a WordPress theme that would run on its own server but be integrated into a larger e-commerce site that was running in a separate CMS. The headers and footers for the site change frequently and the WordPress theme needed to insert itself between the two. The basic outline to tackle this problem is: Create a template in the CMS with an empty content area, and set up eg /blog so that instead of using the CMS it  loads content from the WordPress server. Create a WordPress theme that uses the built-in curl library to read …

WordPress Theme Development Quick Start

David Nash css, html, php, wordpress Leave a Comment

I’ve created plenty of WordPress themes based on designs from clients. This is the process I usually follow. 1. Create a static HTML and CSS template. I create index.html and style.css. 2. Install WordPress 3. In the WordPress folder wp-content/themes/ I create a folder with the name of my new theme. 4. Copy my static HTML to the new theme folder. 5. Modify style.css, add the WordPress stylesheet header: /* Theme Name: THEME_NAME Theme URI: YOUR_WEBSITE Description: THEME_DESC Version: 0.1 Author: YOUR_NAME */ 6. Rename index.html to index.php. Open index.php and replace the reference to style.css with < ?php bloginfo( ...