code Archives - Keith Devon https://keithdevon.com/category/code/ UK-based WordPress developer Thu, 16 Apr 2015 10:17:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.7 How (and why) to use Schema.org on your WordPress website https://keithdevon.com/schema-on-your-wordpress-website/ https://keithdevon.com/schema-on-your-wordpress-website/#comments Thu, 16 Apr 2015 10:17:52 +0000 https://keithdevon.com/?p=1234 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 […]

The post How (and why) to use Schema.org on your WordPress website appeared first on Keith Devon.

]]>
https://keithdevon.com/schema-on-your-wordpress-website/feed/ 8
Add links to WordPress custom excerpts https://keithdevon.com/add-links-wordpress-custom-excerpts/ https://keithdevon.com/add-links-wordpress-custom-excerpts/#respond Thu, 15 Jan 2015 11:03:44 +0000 https://keithdevon.com/?p=1221 By default custom excerpts don’t have a ‘read more’ link of any kind. I wanted my custom excerpts to look the same as my dynamically generated ones. It’s a simple code change:

The post Add links to WordPress custom excerpts appeared first on Keith Devon.

]]>
https://keithdevon.com/add-links-wordpress-custom-excerpts/feed/ 0
Using variables with WordPress translation functions https://keithdevon.com/using-variables-wordpress-translation-functions/ https://keithdevon.com/using-variables-wordpress-translation-functions/#comments Sun, 14 Sep 2014 16:45:50 +0000 https://keithdevon.com/?p=1183 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 […]

The post Using variables with WordPress translation functions appeared first on Keith Devon.

]]>
https://keithdevon.com/using-variables-wordpress-translation-functions/feed/ 1
Full screen background images https://keithdevon.com/full-screen-background-images/ https://keithdevon.com/full-screen-background-images/#respond Fri, 22 Aug 2014 13:46:53 +0000 https://keithdevon.com/?p=1170 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 […]

The post Full screen background images appeared first on Keith Devon.

]]>
https://keithdevon.com/full-screen-background-images/feed/ 0
Passing variables to get_template_part() in WordPress https://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/ https://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/#comments Thu, 31 Jan 2013 12:32:01 +0000 http://keithdevon.wpengine.com/?p=1041 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: include(locate_template('your-template-name.php')); […]

The post Passing variables to get_template_part() in WordPress appeared first on Keith Devon.

]]>
https://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/feed/ 55
WordPress $is_iphone global https://keithdevon.com/wordpress-is_iphone-global/ https://keithdevon.com/wordpress-is_iphone-global/#comments Sun, 14 Oct 2012 14:50:31 +0000 http://keithdevon.wpengine.com/?p=985 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 […]

The post WordPress $is_iphone global appeared first on Keith Devon.

]]>
https://keithdevon.com/wordpress-is_iphone-global/feed/ 2
The PHP ternary operator https://keithdevon.com/the-php-ternary-operator/ https://keithdevon.com/the-php-ternary-operator/#comments Tue, 09 Oct 2012 10:03:25 +0000 http://keithdevon.wpengine.com/?p=969 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 […]

The post The PHP ternary operator appeared first on Keith Devon.

]]>
https://keithdevon.com/the-php-ternary-operator/feed/ 3