ログイン中のユーザーのカテゴリ一覧リンクを出したい
-
ログイン中のユーザーの
・カテゴリ一覧(記事数つき)
・タクソノミー一覧(記事数つき)
を表示させたいと思っています。ページを作り、そのページの独自テンプレートの中に
・カテゴリ一覧
<ul> <?php $args = array( 'author' => $current_user->ID, 'show_option_all' => '', 'orderby' => 'count', 'order' => 'desc', 'style' => 'list', 'show_count' => 1, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'include' => '', 'hierarchical' => 1, 'title_li' => '', 'show_option_none' => __( '' ), 'number' => null, 'echo' => 1, 'depth' => 2, 'current_category' => 0, 'pad_counts' => 1, 'taxonomy' => 'category', ); wp_list_categories( $args ); ?> </ul>
・タクソノミー一覧
<?php $taxonomy = 'items'; $args = array( 'author' => $current_user->ID, 'parent' => 0, 'pad_counts' => true, 'hide_empty' => false ); $terms = get_terms( $taxonomy , $args ); if ( count( $terms ) != 0 ) { echo '<ul>'; foreach ( $terms as $term ) { $term = sanitize_term( $term, $taxonomy ); $term_link = get_term_link( $term, $taxonomy ); if ( is_wp_error( $term_link ) ) { continue; } echo '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a> (' . $term->count . ')'; $term_children = get_term_children( $term->term_id, $taxonomy ); if( count( $term_children ) != 0 ) { echo '<ul>'; foreach ( $term_children as $term_id ) { $term_child = get_term_by( 'id', $term_id, $taxonomy ); $term_child = sanitize_term( $term_child, $taxonomy ); $term_child_link = get_term_link( $term_child, $taxonomy ); if ( is_wp_error( $term_child_link ) ) { continue; } echo '<li><a href="' . esc_url( $term_child_link ) . '">' . $term_child->name . '</a> (' . $term_child->count . ')</li>'; } echo '</ul>'; } echo '</li>'; } echo '</ul>'; } ?>
のように書いているのですが、うまくいきません。
$current_user->ID はログイン中のユーザーのIDを読み込めています。
‘author’ => $current_user->ID,
では使い方を間違っているのでしょうか?どうぞ宜しくお願い致します。
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「ログイン中のユーザーのカテゴリ一覧リンクを出したい」には新たに返信することはできません。