Skip to content

Instantly share code, notes, and snippets.

@jrobinsonc
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrobinsonc/908832758b4f953699d0 to your computer and use it in GitHub Desktop.
Save jrobinsonc/908832758b4f953699d0 to your computer and use it in GitHub Desktop.
Wordpress shortcode: Shortcodes for native functions of wordpress.
<?php
// Use shortcodes within text widgets
add_filter('widget_text', 'do_shortcode');
// wp_nav_menu
add_shortcode('wp_nav_menu', 'wp_nav_menu_shortcode');
function wp_nav_menu_shortcode($atts = array(), $content = '')
{
$atts['echo'] = false;
return wp_nav_menu($atts);
}
// get_search_form
add_shortcode('get_search_form', 'get_search_form_shortcode');
function get_search_form_shortcode($atts = array(), $content = '')
{
return get_search_form(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment