フォーラムへの返信

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • 同様のことがしたくて数ヶ月悩んでいます。

    wp_list_categoryの内容を変数に格納するというところは理解できるのですが
    paginate_links()の使い方がちょっと調べたぐらいでは全くわかりませんでした。

    どこかの英語のサイトに、つぎのようなコードが載っていたので試してみましたが、
    残念ながらエラーとなりました。惜しい気がしますが、どの部分がエラーになっているのか、やはり意味はわかりません。
    (’taxonomy’ =>’category’のところは私の場合タクソノミー’people’に変更しています)

    <?php $args = array( 'taxonomy' => 'category', 'orderby' => 'term_group', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '16', 'parent' => '0', ); $categories = get_categories($args); $numOfItems = 60; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $to = $page * $numOfItems; $current = $to - $numOfItems; $total = sizeof($categories); echo '<ul class="content">'; for ($i=$current; $i<$to; ++$i) { $category = $categories[$i]; if ($category->name) { echo '<li><a href="' . get_term_link($category->slug, 'categories') . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></li>';} } echo '</ul>'; unset($category); echo paginate_links( array( 'base' => add_query_arg( 'cpage', '%#%' ), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($total / $numOfItems), 'current' => $page )); ?>

    タームの一覧をページ分割する方法、検索してもほとんど何も出てこず、このフォーラムが今唯一のヒントとなっています。

1件の返信を表示中 - 1 - 1件目 (全1件中)