Re: ページへのタグ・カテゴリー付加と表示について
永らくありがとうございました › フォーラム › プラグイン › ページへのタグ・カテゴリー付加と表示について › Re: ページへのタグ・カテゴリー付加と表示について
2011 年 2 月 18 日 4:46 PM
#3231
ゲスト
ありがとうございます!
Custom Post Type UIプラグインはじめて知りました。
最初よく意味がわからなかったのですが、
デフォルトのカテゴリ?のような分類をページに設置できるんですね。
ただし、このプラグインではページのカテゴリー、タグは投稿のものと共有になります。
そうなんです。
投稿と共有なので、どのようにわかりやすく分けるかで迷ってました。
ということで、Custom Post Type UIプラグインを導入して
分類名を「contents」、分類表示を「コンテンツ」にしたのでpage.phpに
<code><?php<br /> echo get_the_term_list( $post->ID, 'contents', 'コンテンツ:', ', ', '' );<br /> echo ' | ';<br /> edit_post_link(__('Edit', 'xpress'), '', '');<br /> ?></code>
これで表示させることができました。
また、ページのクエリー?の方は以下のようにして表示させることができました!
<code><?php<br /> global $wpdb,$wp_query;<br /> $disp_count = 10;<br /> $tag_select = '';<br /> $contents_select = '' ;<br /> <br /> if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";<br /> if(empty($contents_select)) $contents_where = ''; else $contents_where = "contents=$contents_select&";<br /> <br /> if (!is_null($wpdb)){<br /> $wp_query->in_the_loop = true; //for use the_tags() in multi lopp<br /> $r = new WP_Query($tag_where .$contents_where."showposts=$disp_count&post_type=page&nopaging=0&post_status=publish");<br /> while($r->have_posts()){<br /> $r->the_post();<br /> ?><br /> <div class="xpress-post" id="post-<?php the_ID(); ?>"><br /> <div class ="xpress-post-header"><br /> <?php if (function_exists('hotDates')) { hotDates(); }?><br /> <div class ="xpress-post-title"><br /> <?php if(function_exists('the_title_attribute')) : ?><br /> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2><br /> <?php else : ?><br /> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2><br /> <?php endif; ?><br /> <br /> </div><br /> </div><br /> <div class="xpress-post-entry"><br /> <?php the_content(); ?><br /> </div><br /> <div class="xpress-link-pages"><?php wp_link_pages() ?></div><br /> <div class ="xpress-post-footer"><br /> <?php<br /> the_time('Y/m/d l');<br /> echo ' - ';<br /> the_author_posts_link();<br /> echo get_the_term_list( $post_id, 'post_tag', ' | Tag: ', ', ', '' );<br /> echo get_the_term_list( $post_id, 'contents', ' | contents ', ', ', '' );<br /> ?><br /> </div><br /> </div><br /> <?php<br /> }<br /> }<br /> ?></code>
これでxpressの幅がだいぶ広がった気がします。
もうひとつ、xpressのブロック「カテゴリ一覧」のように、
ここで設置したcontentsをリスト一覧表示させることも可能でしょうか。
申し訳ありません。