code

  • How (and why) to use Schema.org on your WordPress website

    Search engines have a big problem. There is so much data out there and it’s hard to work out what is what. Humans are great at inferring the context of web content, but this is much more difficult for Google, Bing, Yahoo!, etc.. That’s why the biggest search engines have come together to create a…

    Read More

  • Using variables with WordPress translation functions

    Today I wanted to be able to pass a custom field variable to the WordPress localization (l10n) functions. The custom field is a select field, so all the possible outputs are known. WordPress uses PO and MO files for translations. These are generated by scanning the site for __() and _e() functions, with a programme…

    Read More

  • Full screen background images

    I’m putting this here for my own sanity. If I had £1 for every time I’ve tried to solve this issue! The goal here is to have a background image that covers the whole of the browser window. Ideally we want it to scale, stay centred, and keep it’s correct proportions. My go-to article on…

    Read More

  • Passing variables to get_template_part() in WordPress

    This morning I needed to pass a variable to a file that I was including using the WordPress get_template_part function. I was fiddling around with global variables when I thought there must be a better way. There is. Locate and include You can use the WordPress locate_template function within PHP’s include(). It’s done like this: [code]include(locate_template(‘your-template-name.php’));[/code]…

    Read More

  • WordPress $is_iphone global

    OK, why did nobody tell me about this, and why is it not documented! I just found out today that WordPress does some browser detection of its own. I’ve previously relied on other code libraries for this, but maybe now I can use the ‘WordPress Way’. Detecting mobile in WordPress using $is_iphone In wp-includes/vars.php there…

    Read More

  • The PHP ternary operator

    In my quest to master PHP, I’m going to start investigating some of the bits I’m unfamiliar with, and blogging about them. This morning, I was reading through the excellent “Professional WordPress Plugin Development” by Brad Williams, Ozh Richards and Justin Tadlock (I’ve made a resolution to read a bit every couple of days). In…

    Read More