我制作了一个名为“Education”的自定义帖子类型。使用此自定义帖子类型,我通过“年份”的名称进行了自定义分类。说我是添加了这种自定义后类型大致在10个职位格式为:WordPress的:显示自定义帖子类型Alphabetized自定义分类?
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