WordPress Menu Posts

Making a Menu containing a bunch of Posts is a good way to create a Page with custom ordering/selection. The new WordPress Menus make it really easy to drag and drop and they give you the option to add Posts in the Screen Options tab.

If you want to swap out Menus in your Theme’s Menu Location frequently, it could get PITA to update your Theme every time you make a new Menu. Here’s how to get those Posts to display on your site with only knowing your Theme’s Menu Location slug instead of hard coding the Menu’s slug into your Theme:

// ---	Get the menu locations. Returns array of ( slugs => ids )
//		The menu location slugs are set in the theme's functions.php file. 
//		@see http://codex.wordpress.org/Function_Reference/register_nav_menus
$menuloc 	= get_nav_menu_locations();
$menuid 	= $menuloc[ 'my-themes-menu-location-slug' ];

// ---	Get the currently assigned containing menu and associated posts.
$menuposts 	= wp_get_nav_menu_items( $menuid );

Using CryptX in WP Template

Separating the images from content using strip_tags in a WordPress Template to control the page layout. Using the CryptX plugin to encrypt mailto and email addresses so they won’t get picked up by spam bots. After installing the plugin, you can call the cryptx function directly from the Template to apply the encryption:

if ( function_exists ( 'cryptx' ) ) :
	cryptx ( $content, $text, $css, $echo );
endif;

$content is the string to encrypt.
$text is the string to replace the text inside the alt attribute of the <a> or <img> tags.
$css is the css class to assign to the link.
$echo is set to false to return the result in a variable, true to echo the result to the browser.

Links

CryptX plugin page: wordpress.org/cryptx
CryptX author’s site: weber-nrw.de
PHP function to strip HTML and PHP tags: php.net/strip-tags