Revision: 46779
Updated Code
at May 25, 2011 18:48 by erikportin
Updated Code
<?php /* Short code [a href="pageId" class"clasName"]link[/a] */ /*If you check “add paragraphs automatically†on the widget, WordPress will apply the autop filter — the one that turns your line breaks into paragraph and break tags. If a shortcode is on its own line, it would normally get wrapped in a paragraph tag. The first line prevents that from happening. thanks to http://sillybean.net/2010/02/using-shortcodes-everywhere/ */ add_filter( 'widget_text', 'shortcode_unautop'); //Add shortcode functionality to widgets add_filter('widget_text', 'do_shortcode'); function a_func($atts, $content) { extract(shortcode_atts(array( 'href' => ' ', 'class' => ' ', ), $atts)); $theLink = '<a class="'. $class .'" href="'. get_permalink($href) .'">'. $content .'</a>'; return "{$theLink}"; } add_shortcode('a', 'a_func'); ?>
Revision: 46778
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 24, 2011 23:28 by erikportin
Initial Code
<?php /* Short code [a href="pageId" class"clasName"]link[/a] */ //Add shortcode functionality to widgets add_filter('widget_text', 'do_shortcode'); function a_func($atts, $content) { extract(shortcode_atts(array( 'href' => ' ', 'class' => ' ', ), $atts)); $theLink = '<a class="'. $class .'" href="'. get_permalink($href) .'">'. $content .'</a>'; return "{$theLink}"; } add_shortcode('a', 'a_func'); ?>
Initial URL
Initial Description
Initial Title
Make shortcode for dynamics links for widgets in wordpress
Initial Tags
Initial Language
PHP