Skip to content

Instantly share code, notes, and snippets.

View jtunnicliff's full-sized avatar

Jody Tunnicliff jtunnicliff

View GitHub Profile
@jerewall
jerewall / functions.php
Created February 18, 2015 21:02
Sitemap for Menu
<h1>Sitemap</h1>
[menu name="Sitemap"]
/* Create shortcode to generate menu list in post */
/* Shortcode: [menu name="name-of-menu"] */
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
function words($value, $words = 100, $end = '...')
{
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
if ( ! isset($matches[0]) || strlen($value) === strlen($matches[0])) return $value;
return rtrim($matches[0]).$end;
}
/*
Usage: