<?php add_shortcode( $tag , $func ); ?>
<?php
function projects_view( $atts ) {
$atts = shortcode_atts( array(
'attribute_name' => 'default attribute',
), $atts );
$html = '';
$html .= "you output with attribute is ".$attribute_name;
return $html;
}
add_shortcode( 'projects', 'projects_view' );
If your plugin is designed as a class write as follows:
class Projects {
function projects_view( $atts, $content="" ) {
$atts = shortcode_atts( array(
'attribute_name' => 'default attribute',
), $atts );
return "content = $content";
}
}
add_shortcode( 'projects', array( 'Projects', 'projects_view' ) );
?>
Display proccess in page content
[projects attribute_name="new"]
Display process in php code
<?php echo do_shortcode( $content ) ?>
<?php echo do_shortcode('
[projects attribute_name="new"]') ?>
Call a navigation menu using a shortcode
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
add_shortcode('menu', 'print_menu_shortcode');
Place this in functions.php, then use [menu name="main-menu"] to call the menu in your content (replacing "main-menu" with your menu’s slug, of course).