サポート » マルチサイト » カスタム投稿タイプのダイナミックハイライト

  • 解決済 miemama

    (@miemama)


    はじめまして。
    sight(http://sight.wpshower.com/)というテンプレートをもとにカスタマイズを行い、
    Custom Post Type UIを使用してカスタム投稿タイプの投稿ページを2種類作成しました。

    TOPページをフロントページにし投稿ページをBLOGにしました。
    通常の固定ページが2つあり、その他はカスタム投稿タイプで作成した2つのページを空の固定ページにそれぞれ設定し別々のテンプレートに読み込ませています。

    外観、メニューの設定から各コンテンツをグローバルナビゲーションに設定したのですが、
    カスタム投稿タイプで作成したページのみメニューがハイライトしなく、困っています。

    通常は、表示しているページにいる場合、liタグにクラス名”current-menu-item”がつくはずなのですが、カスタム投稿のliタグにはついていませんでした。

    Custom Post Type UIの設定が原因かと思い色々試したのですがうまくいかず、
    function.phpの中身をみたところ以下の設定がされていました。
    phpにはあまり詳しくなく何が原因かが分からないのですが、
    思うように動作する方法がお分かりの方がおられましたらどうかご教授頂けませんでしょうか。

    ちなみにカスタム投稿タイプの始めに読み込ませているページは
    archive-投稿タイプ名 .phpにしています。

    どうぞ宜しくお願いいたします。

    /*** Navigation ***/

    if ( !is_nav_menu(‘Navigation’) || !is_nav_menu(‘Top menu’) ) {
    $menu_id1 = wp_create_nav_menu(‘Navigation’);
    $menu_id2 = wp_create_nav_menu(‘Top menu’);
    wp_update_nav_menu_item($menu_id1, 1);
    wp_update_nav_menu_item($menu_id2, 1);
    }

    class extended_walker extends Walker_Nav_Menu{
    function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {

    if ( !$element )
    return;

    $id_field = $this->db_fields[‘id’];

    //display this element
    if ( is_array( $args[0] ) )
    $args[0][‘has_children’] = ! empty( $children_elements[$element->$id_field] );

    //Adds the ‘parent’ class to the current item if it has children
    if( ! empty( $children_elements[$element->$id_field] ) )
    array_push($element->classes,’parent’);

    $cb_args = array_merge( array(&$output, $element, $depth), $args);

    call_user_func_array(array(&$this, ‘start_el’), $cb_args);

    $id = $element->$id_field;

    // descend only when the depth is right and there are childrens for this element
    if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {

    foreach( $children_elements[ $id ] as $child ){

    if ( !isset($newlevel) ) {
    $newlevel = true;
    //start the child delimiter
    $cb_args = array_merge( array(&$output, $depth), $args);
    call_user_func_array(array(&$this, ‘start_lvl’), $cb_args);
    }
    $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
    }
    unset( $children_elements[ $id ] );
    }

    if ( isset($newlevel) && $newlevel ){
    //end the child delimiter
    $cb_args = array_merge( array(&$output, $depth), $args);
    call_user_func_array(array(&$this, ‘end_lvl’), $cb_args);
    }

    //end this element
    $cb_args = array_merge( array(&$output, $element, $depth), $args);
    call_user_func_array(array(&$this, ‘end_el’), $cb_args);
    }
    }

1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「カスタム投稿タイプのダイナミックハイライト」には新たに返信することはできません。