عرض واحد من كل مادة فئة فرعية
فئات هي: التصميم
2011/1/21 آخر تحديث:
2008/4/18: المشاركات أحد
وبحثت لأننا أردنا لعرض حالة التحديث على مجموعة من المقالات في كل فئة فرعية من الوالد صفحة الفئة.
( صفحة حاولت أن تمارس هنا. )
تم العثور على إخراج هذه المادة لتحديد الفئة الفرعية التي العلامة التالية في القالب.
query_posts ('حجة')
القدرة على استرجاع البيانات من أجل أن حالة القيام بذلك من خلال إعطاء حجة إلى العلامة أعلاه.
- posts_per_page (صحيح)
- عدد الصفحات لاسترداد
- القط (صحيح)
- (يمكنك تحديد عدة قيم مفصولة بفواصل) معرف فئة للحصول على
هناك أخرى تم حذفها.
حاولت استخدام في الواقع كما هو موضح أدناه.
<ul>
<?php if (have_posts()) : query_posts('posts_per_page=ページ数&cat=カテゴリID&orderby=並べる基準の項目&order=並び順'); ?>
<?php while (have_posts()) : the_post(); ?>
ループ内の処理
<?php endwhile; endif; wp_reset_query(); ?>
</ul>
不満はカテゴリIDを直接指定しなくてはいけない事。
出来ればサブカテゴリのIDを全て取得→ループさせながら上記のhtmlを出力、というのが理想だったけどサブカテゴリのID取得方法が分からず断念・・・。
(2008年8月18日 追記:上記方法は、 こちらの記事でで試してみた。一応成功。)
それが出来ればサブカテゴリが増えても自動で追加されるから便利なんだけど・・・。
仕方ないので一つずつカテゴリIDを指定して出力(サブカテゴリの数だけ同じものを書かなくてはいけない)。
以下が実際のソース。
<h3><a href="<?php bloginfo('wpurl') ?>/install">インストール</a></h3>
<ul>
<?php if (have_posts()) : query_posts('posts_per_page=5&cat=4&orderby=ID&order=desc'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
<h3><a href="<?php bloginfo('wpurl') ?>/setting">ブログ設定</a></h3>
<ul>
<?php if (have_posts()) : query_posts('posts_per_page=5&cat=5&orderby=ID&order=desc'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
<h3><a href="<?php bloginfo('wpurl') ?>/design">デザイン</a></h3>
<ul>
<?php if (have_posts()) : query_posts('posts_per_page=5&cat=7&orderby=ID&order=desc'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
<h3><a href="<?php bloginfo('wpurl') ?>/template-tag">テンプレートタグ</a></h3>
<ul>
<?php if (have_posts()) : query_posts('posts_per_page=5&cat=8&orderby=ID&order=desc'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
ダラダラ書いてるけど違うのは「cat=XX」の箇所だけ。あとサブカテゴリのタイトルかな。
- タグ
- query_posts , カテゴリ別 , 記事一覧
- トラックバックURL




























