This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |