カテゴリトップ問題の解決

このエントリーをはてなブックマークに追加

1. サイトマップの表示を基準に考える。
グローバルナビには、コンテンツが空っぽの、URLの正しいページ(マウスオーバーしたときに適切なURLとなるように)を作成する。

その下にカテゴリトップに持ってきたい記事を含むカテゴリ毎の子記事を作成していく。ページ属性の順序欄に、上から表示したい順に小さい数字を入れていく。

2. グローバルナビのページに来たときのリダイレクト処理をテンプレートページのheader読み込み前の部分 に書く。

$cattops = array( 'product', 'services', 'price', 'case', 'company' );

if (in_array($post->post_name, $cattops)) {
wp_redirect( ‘http://tera.bonito-kbs.com/’ . $post->post_name . ‘/’ . $post->post_name . ’1/’, 301 );
exit;
}

3. サブナビにカテゴリトップ記事を出さない処理とカテゴリトップに持ってきたい記事を表示させる処理をする。これをサブナビの表示処理のところを次のように修正して書く。

    if ( $post->post_parent != 0 ) {
    $cur_id = $post->post_parent;
    wp_list_pages(‘title_li=&child_of=’ . $cur_id);
    } else {
    $cur_id = $post->ID;
    wp_list_pages(‘title_li=&include=’ . $cur_id);
    }
    ?>

カテゴリー: WordPress   パーマリンク

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>