WordPress ShortCodes
(AdWz; Auf dem Weg zum) WP-Plugin – MyShortCodes
Kurze Anweisungen werden in WordPress für Bildlegenden (caption) oder Bildgalerien (gallery) verwendet und können leicht um eigene ShortCodes erweitert werden. Hier eine Idee …

Offline Notizen :: WordPress ShortCodes
Man könnte für das Beispiel Hinweistext …
<div style="border: 1px solid silver; margin: 0pt 0pt 1.5em; padding: 3px; overflow: auto; background-color: rgb(176, 224, 230); color: rgb(17, 0, 0);"> <img src="/wp-content/uploads/..../../info.png" alt="Hinweis" title="Hinweis" style="margin: 4px 8px 0pt 0pt; float: left;" height="24" width="24"> Mein Text für Hinweise. </div>
… schreiben.
Oder einfach einen Shortcode …
[info]Mein Text für Hinweise.[/info]
… verwenden.
Quellcode für die drei ShortCodes “info”, “warn” und “tip”.
<?php /* Plugin Name: MyShortCodes Plugin URI: http://mgsimon.de/2009/12/05/wordpress-shortcodes Description: My short codes for [info]...[/info], [warn]...[/warn] and [tip]...[/tip] Version: 0.1 Author: mgsimon Author URI: http://mgsimon.de */ add_shortcode( 'info', 'sc_info' ); function sc_info( $atts, $content = null ) { return '<div style="background-color:#B0E0E6; border:1px solid silver; color:#110000; margin:0 0 1.5em; overflow:auto; padding: 3px;"> <img src="/wp-content/plugins/MyShortCodes/info.png" alt="Hinweis" title="Hinweis" width="24" height="24" style="margin: 4px 8px 0 0; float:left;"/>'.$content.'</div>'; } add_shortcode( 'warn', 'sc_warn' ); function sc_warn( $atts, $content = null ) { return '<div style="background-color:#FFC0CB; border:1px solid silver; color:#110000; margin:0 0 1.5em; overflow:auto; padding: 3px;"> <img src="/wp-content/plugins/MyShortCodes/warn.png" alt="Warnung" title="Warnung" width="24" height="24" style="margin: 4px 8px 0 0; float:left;" />'.$content.'</div>'; } add_shortcode( 'tip', 'sc_tip' ); function sc_tip( $atts, $content = null ) { return '<div style="background-color:#98FB98; border:1px solid silver; color:#110000; margin:0 0 1.5em; overflow:auto; padding: 3px;"> <img src="/wp-content/plugins/MyShortCodes/tip.png" alt="Tipp" title="Tipp" width="24" height="24" style="margin: 4px 8px 0 0; float:left;" />'.$content.'</div>'; } ?>
Beispiellayout für wichtige Hinweise.
Beispiellayout für Tipps.
weitere Infos zu ShortCodes
- da “WordPress 2.5 Shortcode API“,
- dort “10 incredibly cool WordPress shortcodes” oder
- hier “Shortcode API“
mehr ...
06. Dezember 2009 um 14:49
Klasse Idee! Wo kann ich es downloaden?
06. Dezember 2009 um 15:45
Eigentlich nur ein Beispiel …
http://mgsimon.de/wp-content/uploads/2009/12/MyShortCodes.zip