Snippets

Wordpress

Snippet

Get WordPress Thumbnail URL, Width & Height

Simple function to get the current post’s thumbnail/featured image, but to return it as an array so you can get the thumbnail url, the thumbnail width and the thumbnail height. In the example I’m getting it to use the thumbnail with a lazyload script (specifically this one https://github.com/tuupola/jquery_lazyload). Replace thumbnailsize with either the name of […]

Read more >>

Snippet

Override and set the Facebook open graph locale the Yoast WordPress SEO plugin puts in the WordPress head

The Yoast WordPress plugin adds the Facebook open graph markup to your WordPress head if you enable it. It takes the locale setting from whatever language you have set in the WordPress general settings. You can change it in the settings to whatever locale you need or, if you want to keep the WordPress language […]

Read more >>

Snippet

Remove Yoast WordPress SEO plugin’s search schema markup from the WordPress head

Add this to your theme’s functions.php to remove the search schema that the Yoast WordPress SEO plugin puts in the WordPress head. Particularly if you’re not using the WordPress search on the site!

Read more >>

Snippet

Remove WordPress emoji scripts from head

Removes the new emoji scripts which are in the head from WordPress 4.2 up. Put this in your theme’s functions.php

Read more >>

Snippet

Disable All WordPress Automatic Background Updates

To completely disable all types of automatic updates, core or otherwise, add the above to wp-config.php file:

Read more >>

Snippet

WordPress conditional for custom post type

A simple conditional if statement for custom post types i.e. display different content if it’s the defined custom post type. Just replace custom-post-type with the ID you have given your custom post type in register_post_type within your theme’s functions.php (usually) and then echo the content you want blah blah.

Read more >>

Snippet

WordPress simple list of the current posts tags

Simple function to print a list of tags which the current post is tagged with e.g.

Read more >>

Snippet

WordPress simple get post meta

This function returns the values of the custom fields with the specified key from the specified post. This is the simplest method of simply echoing out the value of a WordPress custom field on a post or custom post. Just replace custom-field-name with the name of the desired custom field you want to echo out.

Read more >>