Skip to content

Instantly share code, notes, and snippets.

View tormjens's full-sized avatar

Tor Morten Jensen tormjens

View GitHub Profile
@tormjens
tormjens / new_get_template_part.php
Created December 11, 2014 09:58
Improved get_template_part
/**
* An improved version for loading template parts.
*
* Load a template part into a template
*
* Makes it easy for a theme to reuse sections of code in a easy to overload way
* for child themes.
*
* Includes the named template part for a theme or if a name is specified then a
* specialised part will be included. If the theme contains no {slug}.php file
@tormjens
tormjens / get_administrative_name.php
Created May 7, 2014 10:41
Get the name of the administrative place based on latitude and longitude from the Google Maps API. Includes transient caching and use of wp_remote_get-function.
function get_administrative_name($lat, $lng, $level = 'administrative_area_level_2', $expire = null) {
if(!$expire)
$expire = 60 * 60 * 24 * 7 * 4; // keep for a month
$transient = 'cached_administrative_name_'. str_replace('.' , '', $lat) .''. str_replace('.' , '', $lng);
if( false === ($place = get_transient( $transient ) ) ) {
$city = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.$lat.','.$lng.'&sensor=false';
@isGabe
isGabe / wp_custom_title_placeholder_text.php
Last active February 25, 2019 21:28
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/