2012-01-11 14 views
0

複数のショートコードを作成したいと思っています。 Wordpressショートコード

[tabs] 

[tab title="1"] 
//content goes here 
[/tab] 

[tab title="2"] 
//content2 goes here 
[/tab] 

[tab title="3"] 
//content4 goes here 
[/tab] 

[/tabs] 

予想される出力:

<ul> 
    <li id="tab1">[tab title="1" goes here]</li> 
    <li id="tab2">[tab title="2" goes here]</li> 
    <li id="tab3">[tab title="3" goes here]</li> 
</ul> 

<ul id="tab1"> 
    <li>Content1</li> 
</ul> 

<ul id="tab2"> 
    <li>Content2</li> 
</ul> 

<ul id="tab3"> 
    <li>Content3</li> 
</ul> 

はどのようにワードプレスであることを行うには?

+1

のようにそれを使用し

function tab_shortcode($atts, $content) { $atts = shortcode_atts(array( 'id' => '' ), $atts); extract ($atts); // gives you the ability to use array keys as variables return '<li id="'. $id.'">'. do_shortcode($content) .'</li>'; } add_shortcode('tab', 'tab_shortcode'); 

"タブ" ショートの作成 "タブの" ショート

function tabs_shortcode($atts, $content) { $atts = shortcode_atts(array( 'id' => '' ), $atts); extract ($atts); // gives you the ability to use array keys as variables return '<ul id="'. $id.'">'. do_shortcode($content) .'</ul>'; } add_shortcode('tabs', 'tabs_shortcode'); 

を作成[公式文書](http://codex.wordpress。 org/Shortcode_API) – balexandre

+0

[ID属性は一意でなければなりません](http://www.w3.org/TR/html4/struct/global.html#h-7.5.2)また[WordPress]( http://wordpress.stackexchange.com/)スタック交換サイト..これはおそらく問題に特定のヘルプを探していないが、WordPressのプラグインを開発する方法のガイダンスを探しているようにそこに投稿する必要があります。 – rlemon

答えて

0
add_shortcode('external', 'externalFunction'); 
function externalFunction($atts,$content = null){ 
    echo do_shortcode('[internal]'.$content.'[/internal]'); 
} 

add_shortcode('internal','internalFunction'); 
function internalFunction($atts, $content=null) 
{ 
    extract(shortcode_atts(
     array(
      "title" => '' 
     ), $atts)); 
     /* do your stuffs here */ 
} 
0

まず今読んで勝るものはありません。この

[tabs id="tab"] 
    [tab id="tab1"] lorem ipsum dolor [/tab] 
    [tab id="tab2"] lorem ipsum dolor [/tab] 
    [tab id="tab3"] lorem ipsum dolor [/tab] 
[/tab] 
関連する問題