私は、「教育」というカスタムの投稿タイプを作っています。このカスタムポストタイプでは、「Years」という名前でカスタム分類を行いました。私はこの形式でこのカスタムポストタイプのおおよその周りの10の記事を追加したと言う:Wordpress:カスタム分類をアルファベット順に表示する
title of custom post type (Education)
、Custom Taxonomy Name (Year)
どのように私は自分のページ上の記事のタイトルを表示し、それは順番に分類名だのでしょうか?
Vimy College 2014
Albatross 2013
Some College 2011
Another College 2010
...
...
(そのような)
はここで、これまでの私のページのコードです:
<?php /* Template Name: Education Page */
get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div>
<?php
// The args here might be constructed wrong
$args = array('post_type' => 'education',
'terms' => 'years',
'orderby' => 'terms',
'order' => 'ASC');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
echo '<h3>';
the_title();
echo '</h3>';
// I don't know what else to put here to display the associated taxonomy name
// (and in sequential order)
endwhile;
?>
</div>
<?php endwhile; endif; ?>
ので明確にするために、最初のhave_posts()
ループだけで実際のページ、および内側のループをエコーポストタイトルを列挙するために上記のカスタム分類法名(この場合は数値)で並べられた形式を生成するはずです。
、素敵な、シンプルでコンパクトなトリックを行う必要があります!ありがとう、これは動作します! – NoReceipt4Panda