Shortcode Examples
The following code shows how shortcodes can be implemented.
<?php function random_picture($atts) { extract(shortcode_atts(array( 'width' => 400, 'height' => 200, 'category' => 'technics', 'mono' => 'no', ), $atts)); $mono = strtolower($mono); $returnvalue = '<img src="http://lorempixel.com/'; if($mono=='yes'){ $returnvalue .= 'g/'; } $returnvalue .= $width . '/'. $height . '/'.$category.'" >'; return $returnvalue; } add_shortcode('picture', 'random_picture'); function lorem_function($atts) { extract(shortcode_atts(array( 'open' => '<p>', 'close' => '</p>', ), $atts)); return $open.'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec nulla vitae lacus mattis volutpat eu at sapien. Nunc interdum congue libero, quis laoreet elit sagittis ut. Pellentesque lacus erat, dictum condimentum pharetra vel, malesuada volutpat risus. Nunc sit amet risus dolor. Etiam posuere tellus nisl. Integer lorem ligula, tempor eu laoreet ac, eleifend quis diam. Proin cursus, nibh eu vehicula varius, lacus elit eleifend elit, eget commodo ante felis at neque. Integer sit amet justo sed elit porta convallis a at metus. Suspendisse molestie turpis pulvinar nisl tincidunt quis fringilla enim lobortis. Curabitur placerat quam ac sem venenatis blandit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam sed ligula nisl. Nam ullamcorper elit id magna hendrerit sit amet dignissim elit sodales. Aenean accumsan consectetur rutrum.'.$close; } add_shortcode('lorem', 'lorem_function'); ?>