サポート » テーマ » グローバルナビゲーションの順番を変えたい

  • 解決済 ryman

    (@ryman)


    ページ属性の順序の数字を変更してもグローバルナビの順番が変わらず困っております。
    「header.php」をどのように修正すれば良いか色々と調べたのですが私の知識不足で解決できず、アドバイスお願いします。

    現在の環境は以下の通りです。
    ・woropressバージョン・・・3.0.1
    ・テーマ・・・StudioPress 1.2

    下記にheader.phpの一部を転記いたしますのでよろしくお願いいたします。

    =以下コード=====

    <div id=”nav”>
    <?php function get_the_pa_ges() {
    global $wpdb;
    if ( ! $these_pages = wp_cache_get(‘these_pages’, ‘pages’) ) {
    $these_pages = $wpdb->get_results(‘select ID, post_title from ‘. $wpdb->posts .’ where post_status = “publish” and post_type = “page” order by ID’);

    }
    return $these_pages;
    }

    function list_all_pages(){

    $all_pages = get_the_pa_ges ();
    foreach ($all_pages as $thats_all){
    $the_page_id = $thats_all->ID;

    if (is_page($the_page_id)) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    }
    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_all->post_title.'”><span>’.$thats_all->post_title.'</span>‘;
    }

    return $output;
    }
    ?>

      <?php

      if (is_home()) {
      $addclass = ‘ class=”current_page”‘;
      } else {
      $addclass = ”;
      }
      echo “<li” . $addclass . “><span>トップページ</span>“;
      echo list_all_pages();?>

    <div class=”cleared”></div>
    </div> <!– Closes Nav –>

    <div class=”topcurvewhite”></div>
    <div id=”main”>

    =以上======

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • rymanさん、こんばんは。
    そうですね。記載のheader.phpだと、ID順(ページを作った順)に並ぶようになっていますね。

    $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by ID');
    部分の order byの後のIDを、menu_orderに書き換えて、
    $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by menu_order');
    にしたら、「ページ属性の順序」の小さい順に並ぶはずです。

    ただ、このテーマの全部のコードを私は確認していませんので、他のページの順序も「ID順」から「ページ属性の順序」に変って、他の部分で不都合が生じるかも知れません。よく、動作を確認してみてくださいね。

    ではまた

    トピック投稿者 ryman

    (@ryman)

    aimaimさん、こんばんは。

    早速、アドバイスいただいた修正を行いました。
    その結果、思い通りにグローバルナビの順番が変更されました。

    また、その他のページでも今のところ問題は発生していません。

    本当にありがとうございます。
    大変助かりました。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「グローバルナビゲーションの順番を変えたい」には新たに返信することはできません。