Mais conteúdo relacionado
Semelhante a WordPressはじめてのプラグイン作成 (20)
WordPressはじめてのプラグイン作成
- 18. ////関数関数
function addtext($content) {function addtext($content) {
$str = "<h3>Hello!!$str = "<h3>Hello!! 愛してるよみんな〜!愛してるよみんな〜!</h3>";</h3>";
return $str.$content;return $str.$content;
}}
add_filter('the_content','addtext');add_filter('the_content','addtext');
ではまず・・・さっそく書きます。
このコードをfunctions.phpに書いてください。
- 24. ヘッダーと関数を記入します。
<?php
/*
Plugin Name: paka3 AddText
Plugin URI: http://www.paka3.com/wpplugin
Description: テキストを末尾に追加するプラグイン
Author: Shoji ENDO
Version: 0.1
Author URI:http://www.paka3.com/
*/
//関数
function addtext($content) {
$str = "<h3>Hello!! 愛してるよみんな〜!</h3>";
return $str.$content;
}
add_filter('the_content','addtext');
?>
addtext.php
作成した関数作成した関数
ヘッダーヘッダー
- 34. ////関数関数
function addtext() {function addtext() {
$str = "<h3>Hello!!$str = "<h3>Hello!! 愛してるよみんな〜!愛してるよみんな〜!</h3>";</h3>";
return $str;return $str;
}}
add_shortcode('ai','addtext');add_shortcode('ai','addtext');
ではまず・・・さっそく書きます。
このコードをfunctions.phpに書いてください。
[ai][ai]
※※ショートコードショートコード
- 35. ショートコードは属性ももてます。
////関数関数
function addtext($atts) {function addtext($atts) {
$atts = extract( shortcode_atts( array($atts = extract( shortcode_atts( array(
'who' => “'who' => “みんな”みんな”
),$atts ));),$atts ));
$str = "<h3>Hello!!$str = "<h3>Hello!! 愛してるよ愛してるよ{$who}{$who}〜!〜!</h3>";</h3>";
return $str;return $str;
}}
add_shortcode('ai','addtext');add_shortcode('ai','addtext');
このコードをfunctions.phpに書いてください。
[ai[ai who=”who=”嫁さん”嫁さん”]]
※※ショートコードショートコード
- 36. ////関数関数
function addtext($atts,$content) {function addtext($atts,$content) {
$str = "<h3>{$content}</h3>";$str = "<h3>{$content}</h3>";
return $str;return $str;
}}
add_shortcode('ai','addtext');add_shortcode('ai','addtext');
ではまず・・・さっそく書きます。
このコードをfunctions.phpに書いてください。
[ai][ai]こんにちは、ラブこんにちは、ラブ&&ピース!!ピース!![/ai][/ai]
※※ショートコードショートコード