- Edit your theme's functions.php and add after <?php:
Code:include 'shortcode.php'; - Create a new file in your theme's directory named shortcode.php
- Paste this:
Code:<?php function underline( $attr, $content = null ) { return '<font style="text-decoration:underline;">' . $content . '</font>'; } add_shortcode('u', 'underline'); ?>
u is the shortcode tag
underline is the function name
<font style="text-decoration:underline;"> is what comes before the content of the shortcode
</font> comes after the shortcode
- To use the shortcode, wrap them with content here [/u ]
[*]To add more, just duplicate the function above and replace the values to suit your needs.
Here's a function for the tag with the post's title used as an alt tag
[INDENT][CODE]function image( $attr, $content = null ) {
return '<img src="' . $content . '" alt="'.get_the_title($ID).'"/>';
}
add_shortcode('img', 'image');[/CODE][/INDENT]
[/LIST]
Read More:
[LIST]
[*][URL="http://codex.wordpress.org/Shortcode_API"]Shortcode API - WordPress Codex[/URL]
[/LIST][/COLOR]