• 26-02-2019, 22:12:50
    #1
    Merhabalar arkadaşlar.

    Tab (sekme) için shortcode fonksiyonu ararken şu sayfaya denk geldim.

    Kodları WordPress temamın functions.php dosyasına eklediğimde site şu hatayı vermeye başladı:
    ( ! ) Parse error: syntax error, unexpected 'if' (T_IF) in functions.php on line 54
    54. satırda ise üstteki sayfada bulunan kodun şu kısmı yer alıyor:
    if( is_array( $GLOBALS['tabs'] ) ){
    Kodun geneli şöyle:
    add_shortcode('tab', 'defaulttab');
    function defaulttabs( $atts, $content = null ) {
        extract( shortcode_atts( array(
        'title' => '',
        'tab' => '1',
        ), $atts ) );
    
        $i = $GLOBALS['tab_count'];
        $GLOBALS['tabs'][$i] = array( 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' =>  $content );
        $GLOBALS['tab_count']++;
    }
    
    add_shortcode('tabs', 'defaulttabs');
    function defaulttab( $atts, $content = null ) {
        $GLOBALS['tab_count'] = 0;
        do_shortcode($content)
        if( is_array( $GLOBALS['tabs'] ) ){
            $i = 1;
            foreach( $GLOBALS['tabs'] as $tab ){
                $tabs[] = '<li><a class="tab" href="#">'.$tab['title'].'</a></li>';
                $panes[] = '<div class="tab'.$i.'" class="tabcontent">' .$tab['content'].'</div>';
                $i++;
            }
            $return = '<div class="tabcontainer"><ul class="selector">'.implode( "n", $tabs ).'</ul>
                <div class="clear"></div>'.implode( "n", $panes ).'</div>';
        }
        return $return;
    }
  • 26-02-2019, 22:14:53
    #2
    Üyeliği durduruldu
    Fonksiyon tanım kodlarında eksiklik olabilir.
  • 26-02-2019, 22:20:05
    #3
    Misafir
    Gözüme carpan

    do_shortcode($content)
    bunun kapali olmamasi sonuna ; ekleyin ve tekrar deneyin
    • Hellscream
    Hellscream bunu beğendi.
    1 kişi bunu beğendi.
  • 26-02-2019, 22:23:06
    #4
    SpyError adlı üyeden alıntı: mesajı görüntüle
    Gözüme carpan

    do_shortcode($content)
    bunun kapali olmamasi sonuna ; ekleyin ve tekrar deneyin
    Teşekkürler hocam hata düzeldi ancak sanırım kod hatalı olsa gerek işlevini görmüyor.