Minimales WordPress Shortcode-Plugin-Beispiel
English
Deutsch
Siehe auch: Minimales WordPress JS-Plugin-Beispiel Minimales WordPress CSS-Plugin-Beispiel
Dieses Plugin erstellt einen einfachen (statischen - keine Parameter) Shortcode in WordPress
Erstellen Sie zuerst ein Verzeichnis für Ihr Plugin in wp-content/plugins/, z.B. wp-content/plugins/my-shortcode-plugin
Speichern Sie den folgenden Code als functions.php im Plugin-Ordner, z.B. wp-content/plugins/my-shortcode-plugin/functions.php
my_shortcode_plugin.php
<?php
/*
Plugin Name: My shortcode plugin
*/
function my_shortcode( $atts , $content = null ) {
return '<h2>Shortcode funktioniert</h2>';
}
add_shortcode( 'my-shortcode', 'my_shortcode' );Aktivieren Sie nun Ihr Plugin im WordPress-Admin-Bereich.
Sie können nun einen Beitrag oder eine Seite erstellen, der/die diesen Code enthält:
shortcode_usage.txt
[my-shortcode][/my-shortcode]was wie folgt gerendert wird:
shortcode_output.txt
Shortcode funktioniert
---------------If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow